-
Notifications
You must be signed in to change notification settings - Fork 17
/
bubble.lua
46 lines (34 loc) · 1 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
bubble = class("bubble")
--"FUCKING BUBBLES!!!!"
-- -The Nostalgia Critic, when he wasn't shit.
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
if not underwater then
local x = math.floor(self.x)+1
local y = math.floor(self.y)+1
if not inmap(x, y) then
return true
end
if not tilequads[map[x][y][1]]:getproperty("water", x, y) then
return true
end
end
return false
end
function bubble:draw()
love.graphics.draw(bubbleimg, math.floor((self.x-xscroll)*16*scale), math.floor((self.y-yscroll-.5)*16*scale), 0, scale, scale, 2, 2)
end