Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Snake
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
equs




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Wed Apr 07, 2004 9:44 pm   Post subject: (No subject)

http://www.compsci.ca/v2/viewtopic.php?t=3625&highlight=snake
equs




PostPosted: Thu Apr 08, 2004 8:16 pm   Post subject: (No subject)

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




PostPosted: Fri Apr 09, 2004 12:02 am   Post subject: (No subject)

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

anyways

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?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
equs




PostPosted: Fri Apr 09, 2004 11:35 am   Post subject: (No 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
Tony




PostPosted: Fri Apr 09, 2004 2:52 pm   Post subject: (No subject)

well for the movement part, its easy
code:

loop
Input.KeyDown()
% input analysis, turns and what not
move
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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: