-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTree.lua
More file actions
38 lines (27 loc) · 871 Bytes
/
Copy pathTree.lua
File metadata and controls
38 lines (27 loc) · 871 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
Tree = Class{}
local Tree_IMAGE = love.graphics.newImage('cactus.png')
-- speed at which the tree should scroll right to left
TREE_SPEED = GROUND_SCROLL_SPEED
-- height of tree image, globally accessible
TREE_HEIGHT = 70
TREE_WIDTH = 35
function Tree:init()
self.x = VIRTUAL_WIDTH
self.height = Tree_IMAGE:getHeight()
-- set the Y to a random value halfway below the screen
self.y = VIRTUAL_HEIGHT - self.height
self.width = Tree_IMAGE:getWidth()
self.remove = false
self.past = false
end
function Tree:update(dt)
--TREE_SPEED = TREE_SPEED + SCROLL_ACCELERATION * dt
if self.x > -TREE_WIDTH then
self.x = self.x - TREE_SPEED * dt
else
self.remove = true
end
end
function Tree:render()
love.graphics.draw(Tree_IMAGE, math.floor(self.x + 0.5), math.floor(self.y))
end