blob: e0d5465236a3b4fbab8bdefd81baa996033102b0 (
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
|
local motionModule = {}
function motionModule.motion(dt)
if character.bola.jump.higher > 0 and love.keyboard.isScancodeDown(button.a) then
jump(dt)
end
if love.keyboard.isScancodeDown(button.left) then
walkLeft(dt)
elseif love.keyboard.isScancodeDown(button.right) then
walkRight(dt)
end
if love.keyboard.isScancodeDown(button.up) then
walkUp(dt)
elseif love.keyboard.isScancodeDown(button.down) then
walkDown(dt)
end
end
function jump(dt)
character.bola.jump.higher = character.bola.jump.higher - dt
character.bola.jump.velocity = character.bola.jump.velocity + character.bola.jump.height * (dt / character.bola.jump.higherMax)
-- quad.bola = character.bola.jump[math.floor(character.bola.jump.start)]
end
function walkLeft(dt)
character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt)
quad.bola = character.bola.walk[math.floor(character.bola.walk.start)]
character.bola.scale.x = -1
end
function walkRight(dt)
character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt)
quad.bola = character.bola.walk[math.floor(character.bola.walk.start)]
character.bola.scale.x = 1
end
function walkUp(dt)
character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt)
character.bola.jump.ground = character.bola.position.y
quad.bola = character.bola.walk[math.floor(character.bola.walk.start)]
end
function walkDown(dt)
character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt)
character.bola.jump.ground = character.bola.position.y
quad.bola = character.bola.walk[math.floor(character.bola.walk.start)]
end
return motionModule
|