summaryrefslogtreecommitdiff
path: root/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua
blob: ff5293d7a76a11dffd77edebfa7b1c980675af08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
game.animation = function(character, dt)
  character.elapsedTime = character.elapsedTime + dt
  if character.elapsedTime > (1 / character.fps) then
--[[
    if character.loop > 0 then
      if loopCounter == nil then
        character.currentFrame = 1
        loopCounter = 1
      elseif loopCounter < loop then
        character.currentFrame = 1
        loopCounter = loopCounter + 1
      else
        character.currentFrame = # character
      end
    elseif character.loop == 0 or character.loop == false then
      character.currentFrame = # character
    elseif character.loop == -1 or character.loop == true then
      character.currentFrame = 1
    end
]]
    if character.currentFrame < # character then
      character.currentFrame = character.currentFrame + 1
    else
      character.currentFrame = 1
    end
    character.elapsedTime = 0
  end
end