forked from Mari0-CE/Mari0-Community-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockdebris.lua
40 lines (31 loc) · 899 Bytes
/
blockdebris.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
blockdebris = class("blockdebris")
function blockdebris:init(x, y, speedx, speedy)
updateranges()
self.x = x
self.y = y
self.speedx = speedx
self.speedy = speedy
self.timer = 0
self.frame = 1
end
function blockdebris:update(dt)
self.timer = self.timer + dt
while self.timer > blockdebrisanimationtime do
self.timer = self.timer - blockdebrisanimationtime
if self.frame == 1 then
self.frame = 2
else
self.frame = 1
end
end
self.speedy = self.speedy + blockdebrisgravity*dt
self.x = self.x + self.speedx*dt
self.y = self.y + self.speedy*dt
if self.y > mapheight then
return true
end
return false
end
function blockdebris:draw()
love.graphics.drawq(blockdebrisimg, blockdebrisquads[spriteset][self.frame], math.floor((self.x-xscroll)*16*scale), math.floor((self.y-yscroll-.5)*16*scale), 0, scale, scale, 4, 4)
end