blob: 61f0ce08acf1c46cda79dde30b559d39e25b0edf (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
local motionModule = {}
function motionModule.motion(dt)
if love.keyboard.isDown(button.left) or love.keyboard.isScancodeDown(button.right) or love.keyboard.isScancodeDown(button.up) or love.keyboard.isScancodeDown(button.down) then
if love.keyboard.isDown(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
else
stand(dt)
end
end
function walkLeft(dt)
character.bola.acceleration = character.bola.acceleration + dt
if character.bola.position.x >= character.bola.origin.x then
if character.bola.acceleration < 3 then
character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - character.bola.acceleration
else
character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - 3
end
end
quad = {
bola = character.bola.walk[math.floor(character.bola.walk.start)]
}
character.bola.scale.x = -1
end
function walkRight(dt)
character.bola.acceleration = character.bola.acceleration + dt
if character.bola.position.x <= windowProfile.mode.width - character.bola.origin.x then
if character.bola.acceleration < 3 then
character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + character.bola.acceleration
else
character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + 3
end
end
quad = {
bola = character.bola.walk[math.floor(character.bola.walk.start)]
}
character.bola.scale.x = 1
end
function walkUp(dt)
character.bola.acceleration = character.bola.acceleration + dt
if character.bola.position.y >= character.bola.origin.y then
if character.bola.acceleration < 3 then
character.bola.position.y = character.bola.position.y - (character.bola.speed * dt) - character.bola.acceleration
else
character.bola.position.y = character.bola.position.y - (character.bola.speed * dt) - 3
end
end
quad = {
bola = character.bola.walk[math.floor(character.bola.walk.start)]
}
end
function walkDown(dt)
character.bola.acceleration = character.bola.acceleration + dt
if character.bola.position.y <= windowProfile.mode.height - character.bola.origin.y then
if character.bola.acceleration < 3 then
character.bola.position.y = character.bola.position.y + (character.bola.speed * dt) + character.bola.acceleration
else
character.bola.position.y = character.bola.position.y + (character.bola.speed * dt) + 3
end
end
quad = {
bola = character.bola.walk[math.floor(character.bola.walk.start)]
}
end
function crouchDown(dt)
character.bola.acceleration = 0
transform.bola.origin.y = character.bola.origin.crouchDown.y[math.floor(character.bola.crouchDown.start)]
quad = {
bola = character.bola.crouchDown[math.floor(character.bola.crouchDown.start)]
}
end
function crouch(dt)
character.bola.acceleration = 0
transform.bola.origin.y = character.bola.origin.crouch.y[math.floor(character.bola.crouch.start)]
quad = {
bola = character.bola.crouch[math.floor(character.bola.crouch.start)]
}
end
function standUp(dt)
character.bola.acceleration = 0
quad = {
bola = character.bola.standUp[math.floor(character.bola.standUp.start)]
}
end
function stand(dt)
character.bola.acceleration = 0
quad = {
bola = character.bola.stand[math.floor(character.bola.stand.start)]
}
end
return motionModule
|