forked from KirbyKid256/mari0_aces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coinblockanimation.lua
50 lines (41 loc) · 925 Bytes
/
coinblockanimation.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
coinblockanimation = class:new()
function coinblockanimation:init(x, y, t, i)
self.x = x
self.y = y
self.timer = 0
self.frame = 1
if t then
self.t = t
if self.t == "collectable" then
self.i = i
self.offsety = 0
self.speedy = -20.5
end
end
end
function coinblockanimation:update(dt)
if self.t == "collectable" then
self.timer = self.timer + dt
while self.timer > 0.098 do
self.frame = self.frame + 1
self.timer = self.timer - 0.098
end
self.speedy = self.speedy + yacceleration*dt
self.offsety = self.offsety + self.speedy*dt
if self.frame >= 6 then
addpoints(-200, self.x, self.y)
return true
end
else
self.timer = self.timer + dt
while self.timer > coinblockdelay do
self.frame = self.frame + 1
self.timer = self.timer - coinblockdelay
end
if self.frame >= 31 then
addpoints(-200, self.x, self.y)
return true
end
end
return false
end