Computer Science Canada Snake Help |
Author: | upthescale [ 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! |
Author: | Clayton [ Thu May 04, 2006 3:03 pm ] | ||
Post 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
|
Author: | upthescale [ Thu May 04, 2006 3:05 pm ] |
Post subject: | |
my box doesn't even move now that it is in a loop!!! |
Author: | upthescale [ Thu May 04, 2006 3:09 pm ] |
Post subject: | |
ok it werks,,, thanks man +5 bits!!!! |
Author: | Clayton [ Thu May 04, 2006 3:14 pm ] | ||
Post subject: | |||
|
Author: | Delos [ Thu May 04, 2006 3:17 pm ] | ||
Post subject: | |||
SuperFreak82 wrote:
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. |
Author: | Clayton [ Thu May 04, 2006 3:41 pm ] |
Post 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 |