forked from alesan99/mari0_ae
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flower.lua
175 lines (156 loc) · 3.7 KB
/
flower.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
flower = class:new()
function flower:init(x, y, t)
--PHYSICS STUFF
self.starty = y
self.x = x-6/16
self.y = y-11/16
self.speedy = 0
self.speedx = 0
self.width = 12/16
self.height = 12/16
self.static = true
self.active = true
self.category = 6
self.mask = {true}
self.destroy = false
self.autodelete = true
self.gravity = 0
self.t = t or "fire"
--IMAGE STUFF
self.drawable = false
self.pipespawnmax = 1
if self.t == "ice" then
self.graphic = iceflowerimg
self.quad = flowerquad[spriteset][1]
elseif self.t == "tanooki" then
self.graphic = itemsimg
self.quad = itemsquad[spriteset][10]
elseif self.t == "feather" then
self.graphic = itemsimg
self.quad = itemsquad[spriteset][11]
elseif self.t == "carrot" then
self.graphic = itemsimg
self.quad = itemsquad[spriteset][12]
elseif self.t == "superball" then
self.graphic = superballflowerimg
self.quad = coinblockquads[spriteset][1]
elseif self.t == "blueshell" then
self.graphic = itemsimg
self.quad = itemsquad[spriteset][16]
elseif self.t == "boomerang" then
self.graphic = itemsimg
self.quad = itemsquad[spriteset][17]
elseif self.t == "hammersuit" then
self.graphic = itemsimg
self.quad = itemsquad[spriteset][14]
elseif self.t == "frogsuit" then
self.graphic = itemsimg
self.quad = itemsquad[spriteset][15]
else
self.graphic = flowerimg
self.quad = flowerquad[spriteset][1]
end
self.offsetX = 7
self.offsetY = 3
self.quadcenterX = 9
self.quadcenterY = 8
self.rotation = 0 --for portals
self.uptimer = 0
self.timer = 0
self.quadi = 1
self.falling = false
self.light = 1
end
function flower:update(dt)
if self.uptimer < mushroomtime then
self.uptimer = self.uptimer + dt
self.y = self.y - dt*(1/mushroomtime)
end
if self.uptimer >= mushroomtime then
if not self.drawable then
self.y = self.starty-27/16
end
self.active = true
self.drawable = true
end
--animate
if self.t == "superball" then
self.quad = coinblockquads[spriteset][coinframe]
elseif (not self.t) or self.t == "fire" or self.t == "ice" then
self.timer = self.timer + dt
while self.timer > staranimationdelay do
self.quadi = self.quadi + 1
if self.quadi == 5 then
self.quadi = 1
end
self.quad = flowerquad[spriteset][self.quadi]
self.timer = self.timer - staranimationdelay
end
end
if self.destroy then
return true
else
return false
end
end
function flower:draw()
if self.uptimer < mushroomtime and not self.destroy then
--Draw it coming out of the block.
love.graphics.draw(self.graphic, self.quad, math.floor(((self.x-xscroll)*16+self.offsetX)*scale), math.floor(((self.y-yscroll)*16-self.offsetY)*scale), 0, scale, scale, self.quadcenterX, self.quadcenterY)
end
end
function flower:passivecollide(a, b)
if self.active and a == "player" then
self:use(b)
end
end
function flower:leftcollide(a, b)
if a == "player" then
self:use(b)
end
return false
end
function flower:rightcollide(a, b)
if a == "player" then
self:use(b)
end
return false
end
function flower:floorcollide(a, b)
if self.active and a == "player" then
self:use(b)
end
end
function flower:ceilcollide(a, b)
if self.active and a == "player" then
self:use(b)
end
end
function flower:jump(x)
end
function flower:use(b)
if self.t == "ice" then
b:grow(7)
elseif self.t == "tanooki" then
b:grow(9)
elseif self.t == "feather" then
b:grow(10)
elseif self.t == "carrot" then
b:grow(11)
elseif self.t == "superball" then
b:grow(13)
elseif self.t == "blueshell" then
b:grow(14)
elseif self.t == "boomerang" then
b:grow(15)
elseif self.t == "hammersuit" then
b:grow(4)
elseif self.t == "frogsuit" then
b:grow(5)
else
b:grow(3)
end
self.active = false
self.destroy = true
self.drawable = false
end