If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Snake game movement problem...

Hi,

Im trying to make a snake game for a coursework at uni... the problem is that i have allowed for the keybaord to control the head of the snake so far, but i it will only move if the key is repeatedly pressed or held down. as tradition in snake games the snake will carry on moving in the last pressed direction... this is what i cannot fathom.

i have tried a while statement, but the applet viewer kinda 'jams' and the dot vanishes.

I am new to java and maybe i was too enthusiatstic and got myself stuck, or im just missing something obvious!

try compiling the code...and u'll understand what i mean.

Here is the complete code of the applet so far, i have only just started it so it isnt far/complex:

I made something like this. I had a direction string that I set to u, d, l, or r based on the key pressed. It ran a thread, looping every .5 or so seconds and checking the value of direction. It modified the variables appropriately.