Author |
Message |
Nairb_12
|
Posted: Sat Jun 07, 2008 7:52 am Post subject: URGENT! Snake Game: How do I make a tail that follows the path of the head and grows larger? |
|
|
I'm remaking the retro game 'Snake' for a school project, and I don't know much about Turing. I've got the motion of the head (lead square) complete, but I have no idea how to approach creating an expandable array of squares that will follow the path taken by the head. Any code or suggestions are greatly appreciated, as my program is due next week! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
A.J
|
Posted: Sat Jun 07, 2008 11:36 am Post subject: Re: URGENT! Snake Game: How do I make a tail that follows the path of the head and grows larger? |
|
|
thats good that you got the head done.
all you have to do now is add squares behind the lead square (store the coordinates in an array or something).
so every time you move:
head moves to the intended direction
following square #1 goes where the head was,
following square #2 goes where following square #1 was,
etc...
so, in theory, every square shifts one while the head moves towards where ot supposed to go |
|
|
|
|
|
jeffgreco13
|
Posted: Mon Jun 09, 2008 9:10 am Post subject: Re: URGENT! Snake Game: How do I make a tail that follows the path of the head and grows larger? |
|
|
OOT (object oriented Turing).
If it's not too late you should read up on this because you can create a 'Square' object that carries an x and y coordinate.
You then create an array of 'Squares'. Square 1, being the head and Square n being the tail simply replaces itself with the coordinate from the one that it follows.
Make yourself a procedure that detects when the head comes in contact with the randomly placed sqaure. That procedure will then add a new 'Sqaure' to the array. |
|
|
|
|
|
Bloodfroxx
|
Posted: Mon Jun 09, 2008 1:32 pm Post subject: RE:URGENT! Snake Game: How do I make a tail that follows the path of the head and grows larger? |
|
|
*Post removed by Dan for insulting another user on the site.* |
|
|
|
|
|
jeffgreco13
|
Posted: Mon Jun 09, 2008 1:41 pm Post subject: RE:URGENT! Snake Game: How do I make a tail that follows the path of the head and grows larger? |
|
|
Now that is just ridiculous^^
A mod is obviously gonna delete that, probably this too, but for everyone who sees that and if Mr. 4 year old Bloodfroxx comes back, I don't even have to chirp or flame... that guy makes his own life look pathetic.
You obviously know him, why don't u just call him and say Mwahahaha. |
|
|
|
|
|
metachief
|
Posted: Tue Jun 10, 2008 12:40 am Post subject: RE:URGENT! Snake Game: How do I make a tail that follows the path of the head and grows larger? |
|
|
Bloodfroxx, you should not use this help forum to place personal messages. That is what the PM system is created for. You are literaly acting like an infant. Consider what you say next time, for it makes you look foolish. |
|
|
|
|
|
Bloodfroxx
|
Posted: Tue Jun 10, 2008 11:19 am Post subject: RE:URGENT! Snake Game: How do I make a tail that follows the path of the head and grows larger? |
|
|
obviously if i posted it, i really don't care if i look foolish metachief, and by the way my own life is pathetic and i am amused that my friend will go on this sight to ask for such a simple thing when really he could have asked one of his friends, like myself, and gotten an answer a lot faster and a far more detailed explanation on how to accomplish his goal |
|
|
|
|
|
|