Snake Help
Author |
Message |
upthescale
|
Posted: Thu May 04, 2006 2:45 pm Post subject: Snake Help |
|
|
You know when you hit a key and the snake wil move...well for me the snake only moves when i hit the key, how can i do it so when i key an arrow key, he will go...because he only goes when i hold down! |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Clayton

|
Posted: Thu May 04, 2006 3:03 pm Post subject: (No subject) |
|
|
think about it, if it is going to move continuously without input, what do you need? a loop. have an if condition then go into the loop. simple
Turing: |
var keys: array char of boolean
loop
Input.KeyDown(keys )
if keys (%whatever arrow) then
loop
%make coordinate changes in the loop(continuous without input)
end if
exit when hasch
end loop
|
|
|
|
|
|
 |
upthescale
|
Posted: Thu May 04, 2006 3:05 pm Post subject: (No subject) |
|
|
my box doesn't even move now that it is in a loop!!! |
|
|
|
|
 |
upthescale
|
Posted: Thu May 04, 2006 3:09 pm Post subject: (No subject) |
|
|
ok it werks,,, thanks man +5 bits!!!! |
|
|
|
|
 |
Clayton

|
Posted: Thu May 04, 2006 3:14 pm Post subject: (No subject) |
|
|
|
|
|
|
|
 |
Delos

|
Posted: Thu May 04, 2006 3:17 pm Post subject: (No subject) |
|
|
SuperFreak82 wrote:
Turing: |
var keys: array char of boolean
loop
Input.KeyDown(keys )
if keys (%whatever arrow) then
loop
%make coordinate changes in the loop(continuous without input)
end if
exit when hasch
end loop
|
A nested loop eh? Not a bad idea, and functional. However, using this approach you'll be left with 4 instances of such loops within your main loop. This might just me being picky, but I would far prefer to use a vectors-and-components approch.
Simply break down your snake movement into its components (in this case very, very simple). If the left button is pressed, the movement components would become (-1, 0); this can then be used in the main loop to change the position of the snake.
And yes, you would end up with 4 instances of these assignments - but this just strikes me as a simpler route to creating the constant motion here. |
|
|
|
|
 |
Clayton

|
Posted: Thu May 04, 2006 3:41 pm Post subject: (No subject) |
|
|
i was thinking more of a procedural approach where you could get the input and pass that to a procedure and run the loop, i just did that to show him the concept of what to do really |
|
|
|
|
 |
|
|