Sign in to follow this  

Snake Game movement help

This topic is 1716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a snake game and I've been stuck on the movement for the last half hour or so and figure it's time to get some assistance on this. I've gone through several possible solutions, but I keep getting the same result. When a new piece to the snake is added, it draws the new block in the correct spot to start with, but when the update method is run, all the snake parts are drawn in the same place. This is my code:

 

LinkedList<WormBlock> wormDataCopy = wormData;
			
			getFirst().setPosition(getFirst().getPosition().add(direction));
			for(int i = 1; i < wormData.size();i++){
				wormData.set(i, wormDataCopy.get(i-1));
			}

 

Any idea what I've done wrong?

Share this post


Link to post
Share on other sites

Ah, I meant remove the tail of the snake, and add it do the head. That will create the illusion of movement, wouldn't it?

And just to make sure I am not embarrassing myself, when you say snake game, you mean the one where the snake move around in 4 directions, and eat apple food to grow bigger, yes?

Edited by ultramailman

Share this post


Link to post
Share on other sites

This topic is 1716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this