Hello folks,
Some time ago in order to learn how SFML works I wrote my personal version of the game 2048. Today i came back to my code with the idea of going some refactor.. Besides many issues, one the most problematic is how the animation are handled, i really think it may be a better way but i have no idea on how to proceed using SFML.
To animate a Sprite, my app every give time just change the position of the sprite object in order to emulate the motion, it happen in two different steps:
- A thread runs in background and update the sprite positions continuously, the frequency of the update depends on the sprite 'speed', if i want a quick moving object the position update will happen very frequently
- The main thread draws the sprite on the rendering window 60 times per seconds
The idea works, since the sprites are animated.. But the effect i think is very poor and my question to you is: How to animate efficiently sf::Sprite object in SFML? Is there any 'proper' way?
For reference:
A video of the game (if you dont want to build everything):
The quality of the video is pretty poor.
Repo for the game:
https://github.com/fjanisze/2048.gitRepo for the animation engine only (with a banal demo to test the code):
https://github.com/fjanisze/simple_animation_engine.gitPlease do not comment the texture quality ecc, i know is everthing ugly
Thanks