I am trying to make a snake game in ChaiLove. I have this code currently:
def update(dt) {
if (gameOver) {
return;
}
t = t + dt
if (t >= 0.08f) {
t = 0.0f
}
else {
return;
}
I have 3 options:
- Move the snake head by 1 pixel on every frame: produces smooth game updates but I can't figure out how to handle the tail;
- Move the snake head by one snake segment on every frame: produces smooth games updates and tail is updated correctly but the gameplay is too fast;
- Move the snake head by one segment on every
0.08f
dt: produces choppy game updates but correct tail updates and gameplay speed.
I want to have the smooth animation of 1) with the correctness of 3). My code is here: https://github.com/dimitrovs/snake/blob/main/main.chai