I'm kind of a beginner in Yabasic but i was trying to make my own version of snake, in the graphicswindow of yabasic. Now I've got a problem because in the snake-game, you would want the snake to keep moving in a certain direction, but when for example 'left' is pressed, it should change direction. So i wanted to give the inkey$ a optional argument, it waits for a second, and if no key is pressed, the snake moves forward. Yet i waits until a key is pressed, which is not the idea. This is the specific part where it seems to go wrong:
(Every block of the snake is a rectangle, (x1,y1 to x2,y2), they change when a key is pressed.)
inkey$(1)
if (inkey$="left") then
x1=x1-40
x2=x2-40
elsif (inkey$="right") then
x1=x1+40
x2=x2+40
elsif (inkey$="up") then
y1=y1-40
y2=y2-40
elsif (inkey$="down") then
y1=y1+40
y2=y2+40
endif
After this, the program will change the x and y automatic, so that the snake moves, and loops (do-loop), to start all over again.
Notging happens until a key is pressed, so the optional argument, the way I placed it, seems to be malfunctioning. I guess it's got something to do with the if-statement... I hope this is fixable.. many thanks already!,
Daan