forked from alesan99/mari0_ae
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmariohammer.lua
137 lines (116 loc) · 2.81 KB
/
mariohammer.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
mariohammer = class:new()
function mariohammer:init(x, y, dir, v)
--PHYSICS STUFF
self.y = y+4/16
self.speedy = (-math.sqrt(2*yacceleration*3.5))--+v.speedy --bobthelawyer?
if dir == "right" then
self.speedx = hammerspeed+v.speedx
self.x = x+3/16
else
self.speedx = (-hammerspeed)+v.speedx
self.x = x-24/16
end
self.width = 16/16
self.height = 16/16
self.active = true
self.static = false
self.category = 13
self.mask = { true,
true, true, false, false, true,
true, true, true, true, false,
true, true, true, true, false,
true, true, true, false, false,
true, true, false, true, true,
false, true, false, false, true,
false, true}
self.destroy = false
self.destroysoon = false
--IMAGE STUFF
self.drawable = true
self.graphic = hammerimg
self.quadi = 1
self.quad = hammerquad[spriteset][1]
self.offsetX = 8
self.offsetY = 0
self.quadcenterX = 8
self.quadcenterY = 8
self.animationdirection = dir
self.mariohammerthrower = v
self.rotation = 0 --for portals
self.timer = 0
end
function mariohammer:update(dt)
--rotate back to 0 (portals)
self.rotation = 0
--animate
self.timer = self.timer + dt
while self.timer > hammeranimationspeed do
self.quadi = self.quadi + 1
if self.quadi == 5 then
self.quadi = 1
end
self.quad = hammerquad[spriteset][self.quadi]
self.timer = self.timer - hammeranimationspeed
end
if self.x < xscroll-1 or self.x > xscroll+width+1 or self.y > mapheight and self.active then
self.mariohammerthrower:mariohammercallback()
self.destroy = true
end
if self.destroy then
return true
else
return false
end
end
function mariohammer:leftcollide(a, b)
--self.x = self.x-.5
self:hitstuff(a, b)
return false
end
function mariohammer:rightcollide(a, b)
--self.x = self.x-.5
self:hitstuff(a, b)
return false
end
function mariohammer:floorcollide(a, b)
self:hitstuff(a, b)
return false
end
function mariohammer:ceilcollide(a, b)
self:hitstuff(a, b)
return false
end
function mariohammer:passivecollide(a, b)
self:ceilcollide(a, b)
return false
end
function mariohammer:hitstuff(a, b)
if mariohammerkill[a] then
if a == "koopaling" and b.t == 9 and not (b.hittimer and b.hittimer > 0) then
addpoints(100, self.x, self.y)
end
b:shotted("right")
if a ~= "bowser" then
addpoints(firepoints[a], self.x, self.y)
end
elseif a == "enemy" then
if b:shotted("right", nil, nil, false, true) ~= false and (not b.resistsenemykill) and (not b.resistshammer) then
addpoints(b.firepoints or 200, self.x, self.y)
else
return false
end
elseif a == "boomboom" then
if b.ducking == false then
b:shotted("right")
else
end
end
end
function mariohammer:explode()
if self.active then
self.mariohammerthrower:mariohammercallback()
self.destroy = true
self.active = false
return true
end
end