I am making a Snake like game for a school project and i need to use an array to make the body parts to the Snake follow the head. Can someone help me please?
no, but i heard that if you want to make the body follow the snake, you should use an array.
and they both extend from the Actor class, but i can change that if needed.
no, but i heard that if you want to make the body follow the snake, you should use an array.
The problem with using an array is that arrays have a fixed length and your snake will probably be growing. And even if it does not grow right now, you may want to implement that later. I have several snake demos on the site with source available for different working methods of doing this. Click on my user profile image to go to my page; on the lower right, select the 'Demos by danpost' collection. You will find 3 snake demos with source.
ya, i looked at them before, but i have no idea what the code in the classes actually mean, and I want to learn about this, not just copy and paste it, is there anyway that i could have any, preferably all, of that code explained?
In your second Demo, can you explain to me how the tail knows how to follow the head? I would post the code that covers things like direction and spawning the tail is almost the entire snake class.