SFML community forums

Help => General => Topic started by: Stormboy on April 04, 2014, 06:01:16 pm

Title: Snake game - block positions
Post by: Stormboy on April 04, 2014, 06:01:16 pm
Hi,
I'm planning to make a snake game and I've pretty much figured out most of the game except one thing: updating the snake's body blocks' position.

Take this scenario for example:
The snake is moving left. User presses the UP key and now the head block starts moving up. Now how should the body blocks' positions (x & y) be updated?

Thanks. :D
Title: Re: Snake game - block positions
Post by: zsbzsb on April 04, 2014, 06:09:22 pm
The head is the only thing that will move to a new position depending on user input. All body segments simply move to the position of the segment that is in front of them.
Title: Re: Snake game - block positions
Post by: Stormboy on April 04, 2014, 06:13:04 pm
The head is the only thing that will move to a new position depending on user input. All body segments simply move to the position of the segment that is in front of them.

Oh never thought of it that way. Thanks again :D

Another question if you don't mind: Which would be the best container for the blocks?
Title: Re: Snake game - block positions
Post by: dabbertorres on April 05, 2014, 05:04:57 am
Check this out whenever you have to decide what kind of container you need:
http://i.imgur.com/OxUhWfm.png
Title: Re: Snake game - block positions
Post by: Stormboy on April 05, 2014, 09:45:20 am
Check this out whenever you have to decide what kind of container you need:
http://i.imgur.com/OxUhWfm.png

Thanks for that :).
Title: Re: Snake game - block positions
Post by: didii on April 06, 2014, 01:08:19 pm
Also this (http://www.cplusplus.com/reference/stl/), if you wan't more detailed information about the different container of STL.