-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBomb.lua
39 lines (29 loc) · 874 Bytes
/
Bomb.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
Bomb = Class{}
local gravity = 25
function Bomb:init()
self.image = love.graphics.newImage('src/images/bomb.png')
self.width = self.image:getWidth()
self.height = self.image:getHeight()
self.x = virtual_width /3 - (self.width / 2)
self.y = virtual_height / 2 - (self.height / 2)
self.dy = 0
end
function Bomb:update(dt)
self.dy = self.dy + gravity * dt
-- jump
if love.keyboard.wasPressed('space') then
self.dy = -5
end
self.y = self.y + self.dy
end
function Bomb:collides(pipe)
if (self.x + 2) + (self.width - 4) >= pipe.x and self.x + 2 <= pipe.x + pipe_width then
if (self.y + 8) + (self.height - 16) >= pipe.y and self.y + 8 <= pipe.y + pipe_height then
return true
end
end
return false
end
function Bomb:render()
love.graphics.draw(self.image, self.x, self.y)
end