Make ChaiLove game updates smooth

41 views Asked by At

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:

  1. 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;
  2. 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;
  3. 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

0

There are 0 answers