summaryrefslogtreecommitdiff
path: root/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua
blob: 3efc9c768b59aa5b955af8973926eedd3cc800ad (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'scripts.game.animation'

game.motion = function(metaSprites, character, dt)
  game.animation(character.stand, dt)
  metaSprites.quad = character.stand[character.stand.currentFrame]

  if character.jump.higher > 0 and character.actionA == true then
    if character.jump.limitButtonJump == false then
--[[
      game.animation(character.jump, dt)
      metaSprites.quad = character.jump[character.jump.currentFrame]
]]

      character.jump.higher   = character.jump.higher - dt
      character.jump.velocity = character.jump.velocity + character.jump.height * (dt / character.jump.higherMax)
    end
  end

  if character.actionLeft == true and character.actionRight == false then
    game.animation(character.walk, dt)
    metaSprites.quad = character.walk[character.walk.currentFrame]

    character.position.x = character.position.x - (character.velocity * dt)
    character.scale.x = -1
  end

  if character.actionRight == true and character.actionLeft == false then
    game.animation(character.walk, dt)
    metaSprites.quad = character.walk[character.walk.currentFrame]

    character.position.x = character.position.x + (character.velocity * dt)
    character.scale.x = 1
  end

  if character.actionLeft == true and character.actionRight == true then
    game.animation(character.stand, dt)
    metaSprites.quad = character.stand[character.stand.currentFrame]
  end

  if character.actionUp == true and character.actionDown == false then
    game.animation(character.walk, dt)
    metaSprites.quad = character.walk[character.walk.currentFrame]

    character.position.y = character.position.y - (character.velocity * dt)
    character.jump.ground = character.position.y
  end

  if character.actionDown == true and character.actionUp == false then
    game.animation(character.walk, dt)
    metaSprites.quad = character.walk[character.walk.currentFrame]

    character.position.y = character.position.y + (character.velocity * dt)
    character.jump.ground = character.position.y
  end

  if character.actionUp == true and character.actionDown == true then
    game.animation(character.stand, dt)
    metaSprites.quad = character.stand[character.stand.currentFrame]
  end
end