forked from Mari0-CE/Mari0-Community-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
itemanimation.lua
29 lines (25 loc) · 1.06 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
itemanimation = class("itemanimation")
function itemanimation:init(x, y, i)
self.x = x
self.y = y
self.i = i
self.timer = 0
self.v = enemiesdata[self.i]
end
function itemanimation:update(dt)
self.timer = self.timer + dt
if enemiesdata[self.i]["directfromblock"] then
table.insert(objects["enemy"], enemy:new(self.x, self.y, self.i, map[self.x][self.y]))
return true
end
if self.timer >= mushroomtime then
table.insert(objects["enemy"], enemy:new(self.x, self.y-1, self.i, map[self.x][self.y]))
return true
end
end
function itemanimation:draw()
local yoffset = self.timer/mushroomtime*1
love.graphics.setScissor((self.x-xscroll-6)*16*scale, (self.y-yscroll-6.5)*16*scale, 176*scale, 80*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