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

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




PostPosted: Wed Jun 01, 2005 2:26 pm   Post subject: Snake Game

Well, i know that there have been a lot of posts on this, but as much as I search through the forum and read the multiple array tutorials available, I just dont understand how it works with snake, and how i would go about creating a snake game.

Its for a school assignment, and I would really appreciate it if anyone could help me out, not tell me the answers, but send me in the right direction or w/e.

would be really appreciated if someone could help.
Thanks a lot cheers!
Sponsor
Sponsor
Sponsor
sponsor
lyam_kaskade




PostPosted: Wed Jun 01, 2005 2:59 pm   Post subject: (No subject)

Ummm...these two made snake games. It might help you.

http://www.compsci.ca/v2/viewtopic.php?t=9050
[url]http://www.compsci.ca/v2/viewtopic.php?t=9035&start=0&postdays=0&postorder=asc&highlight=uncle+worm
[/url]
Cervantes




PostPosted: Wed Jun 01, 2005 3:04 pm   Post subject: (No subject)

Multiple arrays? You mean, multi-dimensional arrays? If so, then yes, you will need those to store the environment that your snake interacts with. Generally, a 0 represents an open space. A 1 would represent a wall.
Your snake should be a flexible array (because he can grow!) of a record that records x and y components.
You'll also need to keep track of the snake's direction. Just use a global variable for that.

I think that should "send [you] in the right direction". On the other hand, you could have already gotten that and are wondering, say, about how to get the segments to follow each other. I don't know, because you haven't specified. If you want help, you're going to have to specify.
evogre3n




PostPosted: Wed Jun 01, 2005 3:16 pm   Post subject: (No subject)

multple array? lol

i ment multiple array tutorials, as in lots od different array tutorials Razz lol


And i know everything you have told me, im just confused on how to use it, perhaps I should think about it some more Razz Twisted Evil
evogre3n




PostPosted: Fri Jun 03, 2005 6:27 am   Post subject: (No subject)

Anymore help plz? Sad
evogre3n




PostPosted: Fri Jun 03, 2005 8:15 am   Post subject: (No subject)

Cervantes wrote:
Multiple arrays? You mean, multi-dimensional arrays? If so, then yes, you will need those to store the environment that your snake interacts with. Generally, a 0 represents an open space. A 1 would represent a wall.
Your snake should be a flexible array (because he can grow!) of a record that records x and y components.
You'll also need to keep track of the snake's direction. Just use a global variable for that.

I think that should "send [you] in the right direction". On the other hand, you could have already gotten that and are wondering, say, about how to get the segments to follow each other. I don't know, because you haven't specified. If you want help, you're going to have to specify.


I dont even understand how to make flexible array Sad im so lost!
MysticVegeta




PostPosted: Fri Jun 03, 2005 3:13 pm   Post subject: (No subject)

code:
var arr : flexible array 1..1 of type


If you want to add dimensions

code:
new arr, upper(arr)+1
Cervantes




PostPosted: Fri Jun 03, 2005 3:47 pm   Post subject: (No subject)

evogre3n wrote:
I dont even understand how to make flexible array Sad im so lost!


You're in luck!

And Mystic, that does not add dimensions. That adds elements. 8)
Lastly, can you please tone down your sig? It's rather long.
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Fri Jun 03, 2005 6:38 pm   Post subject: (No subject)

yeah sry, i am gonna change it, i liked it when you said long and wrong lol they rhyme
evogre3n




PostPosted: Mon Jun 06, 2005 7:44 pm   Post subject: (No subject)

Okay im making some progress with this game.

I finally understand this whole flexible array thing, and i got the outside collision detection, but the self collision is what I cant figure out.

code:
exit when whatdotcolour (snake (1).x, snake (1).y) = red


Ive looked at the Worm game posted in 1st reply, and it seems to work there, but its not working for me, and I even tried to duplicate that set of code, and it still doesnt seem to work, any help is appreciated Very Happy
Cervantes




PostPosted: Mon Jun 06, 2005 8:53 pm   Post subject: (No subject)

For snake, you shouldn't be using whatdotcolour. It just complicates everything. Snake works on a grid system, so, you don't need to worry about checking ranges of values. It's just a single point comparison. Do you know how to use 2D arrays? (check the Tutorial section, if not!) I recommend you use one of those for your map, and fill it with integers (or strings, w/e) that represent different things. ie. 0 = empty, 1 = wall, 2 = apple. Then just take the x and y position of the snakes head, plop that into your grid array (like this:
code:
if grid (snake (1).x, snake (1).y) = "2" then  %you ate an apple!

) and voila, you've got your collision detection.
evogre3n




PostPosted: Mon Jun 06, 2005 8:56 pm   Post subject: (No subject)

ive read through this tutorial several times, and I am just not understanding it one bit.

If you could, walk me through it, or something, I really am lost Embarassed
evogre3n




PostPosted: Mon Jun 06, 2005 10:00 pm   Post subject: (No subject)

SOrry for the double post.

This is really starting to bug me. My teacher says i cant switch games and this assignment is due friday and worth 25% of my mark, and its just killing me that I cant even begin this, its really agravating.

If someone experienced could please help, i basically am a total noob at this. What we learned in tech this year was not enough for me to gain the ability to code this game, and i am just really lost.

anyone, plz help. thanks alot Sad
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  [ 13 Posts ]
Jump to:   


Style:  
Search: