Search the Community
Showing results for tags 'smooth animation'.
Found 1 result
vsudakov posted a topic in 2DHey guys, Sorry if it is trivial stuff, but I have not found any solution to this issue anywhere. What I have: I have a snake grid-based game with enemies which could move as well. Snake speed can vary and it could move faster or slower, as well as the enemies speed. The animation is independent of the rest of the game, so I just move snake and enemies every N ms one tile and then redraw their positions. What is the issue: This animation does not provide smooth snake movement, because it moves by tiles (120px) and I am struggling to make a smooth snake and enemies movement. What have I tried: I tried to move enemy and snake every 30 frames and then make a tween animation with 30 frames delay to the destination enemy/snake x/y coordinates. When the snake moved faster, I waited 20 frames. This solution is really ugly and if frames drop occurs, the whole game starts to freeze. Also, different fps provide different game speed. Please advise me how I can achieve the smooth movement, I want to have the animation independent of the main game loop which moves everything by tiles, and I want to have the ability to increase/decrease the speed of snake and enemies. Thanks!