-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathitemanimation.lua
46 lines (39 loc) · 1.37 KB
/
itemanimation.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
itemanimation = class:new()
function itemanimation:init(x, y, i, size)
self.x = x
self.y = y
self.i = i
self.timer = 0
self.size = size
self.v = enemiesdata[self.i]
if self.size and self.v.mushroomifmariosmall and self.size < 2 then
local mushroomenemy = "mushroom"
if type(self.v.mushroomifmariosmall) == "string" then
mushroomenemy = self.v.mushroomifmariosmall
end
self.i = mushroomenemy
self.v = enemiesdata[self.i]
end
if self.v.nocoinblockanimation then
self:spawn()
end
end
function itemanimation:update(dt)
self.timer = self.timer + dt
if self.timer >= mushroomtime then
self:spawn()
end
if self.instantdelete then
return true
end
end
function itemanimation:draw()
local yoffset = self.timer/mushroomtime*1
love.graphics.setScissor((self.x-xscroll-6)*16*screenzoom*scale, (self.y-yscroll-6.5)*16*screenzoom*scale, 176*screenzoom*scale, 80*screenzoom*scale)
love.graphics.draw(self.v.graphic, self.v.quad, math.floor(((self.x-xscroll-.5-self.v.width/2+(self.v.spawnoffsetx or 0))*16+self.v.offsetX)*scale), math.floor(((self.y-yscroll-yoffset-self.v.height+(self.v.spawnoffsety or 0))*16-self.v.offsetY)*scale), 0, scale, scale, self.v.quadcenterX, self.v.quadcenterY)
love.graphics.setScissor()
end
function itemanimation:spawn()
table.insert(objects["enemy"], enemy:new(self.x, self.y-1, self.i, map[self.x][self.y]))
self.instantdelete = true
end