forked from KirbyKid256/mari0_aces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
energycatcher.lua
143 lines (122 loc) · 2.71 KB
/
energycatcher.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
energycatcher = class:new()
function energycatcher:init(x, y, dir, r)
--PHYSICS STUFF
self.cox = x
self.coy = y
self.x = x-1
self.y = y-1
self.width = 8/16
self.height = 16/16
self.static = true
self.active = true
self.category = 4
self.gravity = 0
self.portalable = false
self.dir = dir or "right"
self.r = r
if self.r and self.r ~= "link" then
local v = convertr(self.r, {"string", "bool"}, true)
--DIR
self.dir = v[1]
--OFFSET?
self.offset = v[2]
if self.offset then
if self.dir == "left" or self.dir == "right" then
self.y = self.y + .5
else
self.x = self.x + .5
end
end
end
self.rotation = 0
self.mask = {true}
--IMAGE STUFF
self.drawable = true
self.graphic = energylauncherimage
self.quad = energylauncherquad[2][1]
self.offsetX = 8
self.offsetY = 0
self.quadcenterX = 8
self.quadcenterY = 8
if self.dir == "right" then --multiple directions. This code is so bad I feel bad :(
self.animationdirection = "right"
elseif self.dir == "left" then
self.animationdirection = "left"
self.offsetX = 0
self.x = self.x + 8/16
elseif self.dir == "up" then
self.rotation = -math.pi/2
self.y = self.y + 8/16
self.offsetY = 8
self.width = 16/16
self.height = 8/16
elseif self.dir == "down" then
self.rotation = math.pi/2
self.width = 16/16
self.height = 8/16
end
self.out = false
self.outtable = {}
self.colls = nil
self.falling = false
end
function energycatcher:addoutput(a, t)
table.insert(self.outtable, {a, t})
end
function energycatcher:update(dt)
end
function energycatcher:activate()
if self.activated then
return false
end
self.quad = energylauncherquad[2][2]
for i = 1, #self.outtable do
if self.outtable[i][1].input then
self.outtable[i][1]:input("on", self.outtable[i][2])
end
end
self.activated = true
end
function energycatcher:leftcollide(a, b)
if self:globalcollide(a, b) then
return false
end
if a == "energyball" and self.dir == "left" then
self:activate()
end
return false
end
function energycatcher:rightcollide(a, b)
if self:globalcollide(a, b) then
return false
end
if a == "energyball" and self.dir == "right" then
self:activate()
end
return false
end
function energycatcher:ceilcollide(a, b)
if self:globalcollide(a, b) then
return false
end
if a == "energyball" and self.dir == "up" then
self:activate()
end
end
function energycatcher:globalcollide(a, b)
end
function energycatcher:floorcollide(a, b)
if self:globalcollide(a, b) then
return false
end
if a == "energyball" and self.dir == "down" then
self:activate()
end
if a == "player" then
playsound(blockhitsound) --make sound when hit by mario
end
end
function energycatcher:passivecollide(a, b)
self:leftcollide(a, b)
return false
end