-
Notifications
You must be signed in to change notification settings - Fork 106
/
bubble.lua
33 lines (24 loc) · 713 Bytes
/
bubble.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
bubble = class:new()
--"FUCKING BUBBLES!!!!"
-- -The Nostalgia Critic
function bubble:init(x, y)
self.x = x
self.y = y
self.speedy = -bubblesspeed
end
function bubble:update(dt)
self.speedy = self.speedy + (math.random()-0.5)*dt*100
if self.speedy < -bubblesspeed-bubblesmargin then
self.speedy = -bubblesspeed-bubblesmargin
elseif self.speedy > -bubblesspeed+bubblesmargin then
self.speedy = -bubblesspeed+bubblesmargin
end
self.y = self.y + self.speedy*dt
if self.y < bubblesmaxy then
return true
end
return false
end
function bubble:draw()
love.graphics.draw(bubbleimg, math.floor((self.x-xscroll)*16*scale), math.floor((self.y-.5)*16*scale), 0, scale, scale, 2, 2)
end