-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobstacle.lua
More file actions
44 lines (36 loc) · 718 Bytes
/
obstacle.lua
File metadata and controls
44 lines (36 loc) · 718 Bytes
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
Class = require "lib/hump.class"
Obstacle = Class {
init = function(self, x, y, speed, image)
self.x = x
self.y = y
self.speed = speed
self.image = image
self.hidden = false
end,
width = 173,
height = 45,
}
function Obstacle:update(dt)
self.x = self.x - self.speed * dt
end
function Obstacle:draw()
if self.hidden ~= true then
love.graphics.draw(self.image, self.x, self.y)
end
end
function Obstacle:isNear()
return self.x > 50 and self.x < 200
end
function Obstacle:stop()
self.speed = 0
end
function Obstacle:continue()
self.hidden = true
self.speed = 200
end
function Obstacle:stopplayer()
if self.x <= 38 then
self.speed = 200
self.x = 38
end
end