SFML community forums

Help => General => Topic started by: meistertigran on December 28, 2012, 12:35:36 pm

Title: How can i get in sfml the previous position of a sprite?
Post by: meistertigran on December 28, 2012, 12:35:36 pm
I'm trying to write a Classical Snake game, and i need to get the previous position of the head from my snake to create the first part of the snake body, and then the next part with the previous position of the first body part and so on.
Any Ideas ?
Sorry for my bad English.
Title: Re: How can i get in sfml the previous position of a sprite?
Post by: Nexus on December 28, 2012, 12:45:50 pm
Wrong forum, correct would be Help->General.

Why don't you just simply store the previous position? If you don't know how to do that, you should learn some more C++ before you approach game programming...

Anyway, I would model the snake as a sequence (STL container) of segments. Each time step, you remove the tail segment, and insert a new head segment at the front. You don't need to relocate segments.
Title: Re: How can i get in sfml the previous position of a sprite?
Post by: meistertigran on December 28, 2012, 12:54:13 pm
Good idea. Thanks.