-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmovementfunction.lua
185 lines (170 loc) · 6.29 KB
/
movementfunction.lua
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
------------------------------------------------------------------
function movingMotion()
if player0 == nil or GameSettings.playerHasDied == true or GameSettings.quitGameNow == true or GameSettings.levelIsCleared == true or GameFile.hitPoints <= 0 then
Runtime:removeEventListener("enterFrame", movingMotion)
return false
end
--print(" upArrow._touch_num = "..tostring(upArrow._touch_num))
--print(" downArrow._touch_num = "..tostring(downArrow._touch_num))
--print(" rightArrow._touch_num = "..tostring(rightArrow._touch_num))
--print(" leftArrow._touch_num = "..tostring(leftArrow._touch_num))
player0.x = player0.x + motionx
player0.y = player0.y + motiony
player0.hitBox.x = player0.x
player0.hitBox.y = player0.y
if (GameSettings.SpeedChain > 0 or GameSettings.UnlimitedChain > 0) then
iOh = 250
iUg = 105
elseif GameFile.Speed > 4 or GameFile.playerName == "Dynas" then
iOh = 180
iUg = 95
elseif GameSettings.SpeedChain == 0 or GameSettings.UnlimitedChain == 0 or GameFile.Speed == 4 then
iOh = 105
iUg = 55
end
if GameSettings.playerIsFirstMoving == 0 or GameSettings.lockStatus == true or GameSettings.gymIsCleared == 1 then
GameSettings.playerIsMoving = 0
downArrow._touch_num = 0
upArrow._touch_num = 0
leftArrow._touch_num = 0
rightArrow._touch_num = 0
--player0:setSequence("stopped")
--player0:play()
--GameSettings.playerIsDirection = nil
end
if GameSettings.lockStatus == false and GameSettings.gymIsCleared == 0 then
if spriteCallNum < 2 and (GameSettings.playerIsMoving == 1 and GameSettings.playerIsDirection == "right") or (GameSettings.playerIsFirstMoving == 1 and GameSettings.playerIsDirection == "right") then
player0.xScale = Hr.heroSc
GameSettings.playerIsMoving = 1
if rightArrow._touch_num < 11 then
rightArrow._touch_num = rightArrow._touch_num+5
leftArrow._touch_num = 0
player0:setSequence("walking")
player0:play()
if GameSettings.SpeedChain > 0 or GameSettings.UnlimitedChain > 0 or GameFile.Speed > 10 then
player0:setSequence("running")
player0:play()
end
if GameSettings.SpeedChain > 0 or GameSettings.UnlimitedChain > 0 then
player0:setSequence("running")
player0:play()
end
end
GameSettings.DefenseCharge = 0
local vx, vy = player0:getLinearVelocity()
if vx >= iOh then
player0:setLinearVelocity(vx * 0.8, vy * 0.01)
end
player0:applyForce(player0.xScale * 35, 0, vx, player0.y)
end
end
if GameSettings.lockStatus == false and GameSettings.gymIsCleared == 0 then
if spriteCallNum < 2 and (GameSettings.playerIsMoving == 2 and GameSettings.playerIsDirection == "left") or (GameSettings.playerIsFirstMoving == 1 and GameSettings.playerIsDirection == "left") then
player0.xScale = Hr.heroSc*-1
GameSettings.playerIsMoving = 2
if leftArrow._touch_num < 11 then
leftArrow._touch_num = leftArrow._touch_num+5
rightArrow._touch_num = 0
player0:setSequence("walking")
player0:play()
if GameSettings.SpeedChain > 0 or GameSettings.UnlimitedChain > 0 or GameFile.Speed > 10 then
player0:setSequence("running")
player0:play()
end
if GameSettings.SpeedChain > 0 or GameSettings.UnlimitedChain > 0 then
player0:setSequence("running")
player0:play()
end
end
GameSettings.DefenseCharge = 0
local vx, vy = player0:getLinearVelocity()
if vx <= iOh*-1 then
player0:setLinearVelocity(vx * 0.8, vy * 0.01)
end
player0:applyForce(player0.xScale * 35, 0, vx, player0.y)
end
end
if GameSettings.lockStatus == false and GameSettings.gymIsCleared == 0 then
if (GameSettings.playerIsMoving == 3 and GameSettings.playerIsDirection == "up") or (GameSettings.playerIsFirstMoving == 1 and GameSettings.playerIsDirection == "up") then
GameSettings.playerIsMoving = 3
if upArrow._touch_num < 11 then
upArrow._touch_num = upArrow._touch_num+5
rightArrow._touch_num = 0
player0:setSequence("walking")
player0:play()
if GameSettings.SpeedChain > 0 or GameSettings.UnlimitedChain > 0 or GameFile.Speed > 10 then
player0:setSequence("running")
player0:play()
end
if GameSettings.SpeedChain > 0 or GameSettings.UnlimitedChain > 0 then
player0:setSequence("running")
player0:play()
end
end
GameSettings.DefenseCharge = 0
local vx, vy = player0:getLinearVelocity()
if vy <= iUg*-1 then
player0:setLinearVelocity(vx * 0.8, vy * 0.01)
end
player0:applyForce(0, -70, player0.x, vy)
end
end
if GameSettings.lockStatus == false and GameSettings.gymIsCleared == 0 then
if (GameSettings.playerIsMoving == 4 and GameSettings.playerIsDirection == "down") or (GameSettings.playerIsFirstMoving == 1 and GameSettings.playerIsDirection == "down") then
GameSettings.playerIsMoving = 4
if downArrow._touch_num < 11 then
downArrow._touch_num = downArrow._touch_num+5
rightArrow._touch_num = 0
player0:setSequence("walking")
player0:play()
if GameSettings.SpeedChain > 0 or GameSettings.UnlimitedChain > 0 or GameFile.Speed > 10 then
player0:setSequence("running")
player0:play()
end
if GameSettings.SpeedChain > 0 or GameSettings.UnlimitedChain > 0 then
player0:setSequence("running")
player0:play()
end
end
GameSettings.DefenseCharge = 0
local vx, vy = player0:getLinearVelocity()
if vy <= iUg*-1 then
player0:setLinearVelocity(vx * 0.8, vy * 0.01)
end
player0:applyForce(0, 70, player0.x, vy)
end
end
if GameSettings.isPaused == true then
GameSettings.DefenseCharge = 0
GameSettings.playerIsMoving = 0
player0:setSequence("stopped")
player0:play()
end
if GameSettings.playerIsMoving == 0 then
GameSettings.playerMoveAttack = 0
local vx, vy = player0:getLinearVelocity()
player0:setLinearVelocity(vx * 0.4, vy* 0.4)
end
--[[
print(player0.y)
print(fT-15)
]]
if player0.y <= GameSettings.upperHeight then
player0.y = GameSettings.upperHeight
end
if player0.y >= eH then
player0.y = eH
end
if player0.x <= aG+40 then
player0.x = aG+40
end
yUh = ((aH-qWy))*-1
if player0.x >= yUh then
player0.x = yUh
end
if GameSettings.playerHasDied == true or GameSettings.quitGameNow == true or GameSettings.levelIsCleared == true or GameSettings.gymIsCleared == true then
Runtime:removeEventListener("enterFrame", movingMotion)
end
end
Runtime:addEventListener("enterFrame", movingMotion)
------------------------------------------------------------------