forked from Mari0-CE/Mari0-Community-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bowser.lua
229 lines (193 loc) · 5.12 KB
/
bowser.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
bowser = class("bowser")
function bowser:init(x, y, i)
--PHYSICS STUFF
self.x = x+4
self.y = y-27/16
self.level = i or marioworld
self.startx = x+12
self.starty = y
self.speedy = 0
self.speedx = 0
self.width = 30/16
self.height = 28/16
self.static = false
self.active = true
self.emancipatecheck = true
self.category = 16
self.mask = { true,
false, false, false, false, true,
false, true, false, true, false,
false, false, true, true, false,
true, true, false, false, true,
false, true, true, false, false,
true, false, true, true, true}
self.gravity = bowsergravity
--IMAGE STUFF
self.drawable = true
self.graphic = bowserimg
self.quad = bowserquad[1][1]
self.walkframe = 1
self.offsetX = 14
self.offsetY = -2
self.quadcenterX = 16
self.quadcenterY = 12
self.rotation = 0 --for portals
self.gravitydirection = math.pi/2
self.jump = false
self.animationtimer = 0
self.animationdirection = "right"
self.fireframe = 1
self.timer = 0
self.hammertimer = 0
self.hammertime = 1 --Stop!
self.hammers = false
if self.level >= 6 then
self.hammers = true
end
self.hp = bowserhealth
self.shot = false
self.fall = false
self:newtargetx("right")
end
function bowser:update(dt)
if self.shot then
self.speedy = self.speedy + shotgravity*dt
self.x = self.x+self.speedx*dt
self.y = self.y+self.speedy*dt
if self.speedy > bowserfallspeed then
self.speedy = bowserfallspeed
end
return false
else
if self.speedy > bowserfallspeed then
self.speedy = bowserfallspeed
end
self.rotation = unrotate(self.rotation, self.gravitydirection, dt)
if not self.fall then
self.animationtimer = self.animationtimer + dt
while self.animationtimer > bowseranimationspeed do
self.animationtimer = self.animationtimer - bowseranimationspeed
if self.walkframe == 1 then
self.walkframe = 2
else
self.walkframe = 1
end
end
if self.x < self.targetx then
self.speedx = bowserspeedforwards
if self.x+self.speedx*dt >= self.targetx then
self:newtargetx("left")
end
else
self.speedx = -bowserspeedforwards
if self.x+self.speedx*dt <= self.targetx then
self:newtargetx("right")
end
end
--stop, hammertime
if self.hammers and self.backwards == false then
self.hammertimer = self.hammertimer + dt
while self.hammertimer > self.hammertime do
table.insert(objects["enemy"], enemy:new(self.x+4/16, self.y+.5, "hammer", {}))
self.hammertimer = self.hammertimer - self.hammertime
--new delay
self.hammertime = bowserhammertable[math.random(#bowserhammertable)]
end
end
end
if self.backwards == false and firestarted and firetimer > firedelay-0.5 then
self.fireframe = 2
self.speedx = 0
else
self.fireframe = 1
end
self.quad = bowserquad[self.fireframe][self.walkframe]
--left of player override
if not self.fall then
if objects["player"][getclosestplayer(self.x+15/16)].x > self.x+15/16 and self.jump == false then
self.animationdirection = "left"
self.speedx = bowserspeedbackwards
self.backwards = true
else
self.backwards = false
self.animationdirection = "right"
self.timer = self.timer + dt
if self.timer > bowserjumpdelay and self.jump == false then
self.speedy = -bowserjumpforce
self.jump = true
self.timer = self.timer - bowserjumpdelay
end
end
end
end
return false
end
function bowser:draw()
--just for the hammers
if not self.fall and not self.backwards then
if self.hammertimer > self.hammertime - bowserhammerdrawtime then
love.graphics.draw(enemiesdata["hammer"].graphic, enemiesdata["hammer"].quad, math.floor((self.x-xscroll)*16*scale), (self.y-yscroll-.5-11/16)*16*scale, 0, scale, scale)
end
end
end
function bowser:newtargetx(dir)
if dir == "right" then
self.targetx = self.startx-1-math.random(2)
else
self.targetx = self.startx-7-math.random(2)
end
end
function bowser:shotted(dir)
self.hp = self.hp - 1
if self.hp == 0 then
self:firedeath()
end
end
function bowser:firedeath()
playsound("shot")
playsound("bowserfall")
self.shot = true
self.speedy = -shotjumpforce
self.direction = dir or "right"
self.active = false
self.gravity = shotgravity
self.speedx = 0
addpoints(firepoints["bowser"], self.x+self.width/2, self.y)
--image
if marioworld <= 7 then
self.graphic = decoysimg
self.quad = decoysquad[marioworld]
end
end
function bowser:leftcollide(a, b)
if a == "player" then
return false
end
end
function bowser:rightcollide(a, b)
if a == "player" then
return false
end
end
function bowser:ceilcollide(a, b)
if a == "player" then
return false
end
end
function bowser:startfall()
end
function bowser:floorcollide(a, b)
if self.jump then
self.jump = false
self.timer = 0
end
if a == "player" then
return false
end
end
function bowser:startfall()
self.jump = true
end
function bowser:emancipate(a)
self:shotted()
end