Computer Science Canada


Author:  equs [ Wed Apr 07, 2004 9:41 pm ]
Post subject:  Snake

do you know where i cna find programs for snake?
And could anyone explain how would snake work and the grid system?

Author:  Paul [ Wed Apr 07, 2004 9:44 pm ]
Post subject:

Author:  equs [ Thu Apr 08, 2004 8:16 pm ]
Post subject: 

can anyone explain to me how the grid system is supposed to work and the flexible array?

Author:  Tony [ Fri Apr 09, 2004 12:02 am ]
Post subject: 

hah, should have said you're from Shannon's class before Wink


flexible arrays are just like normal arrays, but you can change their size during run time. Not really neccessary, just better resource managment as it takes up only as much memory as it needs at a given time. You can easily get away with array 1..max size you think it will be at this level.

what do you mean by grid system? as in 2D grid that holds snake's locations?

Author:  equs [ Fri Apr 09, 2004 11:35 am ]
Post subject: 

what my logic for the game of snake is gonna be is that its gonna be a grid and the snake is going to go around that grid. When it goes on a grid where food is its gonna eat it. Also there will be another ball, a red ball, and when the snake eats that it will die and when it crahses into itself. IM wondering a couple things. How to alsways keep it moving and how would i mkae the snake eat the things and how would i do this? I cant seem to understand some of he codes for snake.
ty joshua

Author:  Tony [ Fri Apr 09, 2004 2:52 pm ]
Post subject: 

well for the movement part, its easy

% input analysis, turns and what not
end loop

unlike getch, Input.KeyDown does not pause the execution waiting for input, it just writes down everything that is pressed at the moment and carries on.

As for eating food, once the 'head' is in the same grid location as the 'food', you set grow flag to true and in movement procedure you extend the snake by 1 length point and create the tail where old tail used to be located before it moved.