-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
38 lines (30 loc) · 912 Bytes
/
main.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
local block = require('block')
block_delay = 0.5
function love.load()
blocks = {}
block_timer = 0
stripy = love.graphics.newImage('img/gray-stripey.cat')
slate = love.graphics.newImage('img/slate-gray.cat')
cat1 = love.math.random() * love.graphics.getHeight()
cat2 = love.math.random() * love.graphics.getHeight()
end
function love.update(dt)
block_timer = block_timer + dt
if block_timer >= block_delay then
block_timer = block_timer - block_delay
local length = love.math.random() * 30 + 40
local y = love.math.random() * love.graphics.getHeight()
local newblock = block.create(love.graphics.getWidth() + length, y, length)
table.insert(blocks, newblock)
end
for i, block in ipairs(blocks) do
block.x = block.x - 1
end
end
function love.draw()
for i, block in ipairs(blocks) do
block:draw()
end
love.graphics.draw(stripy, 10, cat1)
love.graphics.draw(slate, 10, cat2)
end