-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
62 lines (53 loc) · 1.65 KB
/
main.lua
File metadata and controls
62 lines (53 loc) · 1.65 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require 'middleclass'
require 'character'
require 'plateform'
require 'camera'
function love.load()
love.graphics.setBackgroundColor(30, 0, 70)
background1 = love.graphics.newImage("background1.png")
background2 = love.graphics.newImage("background2.png")
--love.sensor.enable("TYPE_ACCELEROMETER")
--acc = 0
c = Character:new()
camera = Camera:new()
step = 300
done = step
plateforms = {}
generate(0, step)
end
function love.update(dt)
if -camera.y + 480/2 > done - 480 then
generate(done, done+step)
done = done + step
print('generated')
end
c:update(dt)
camera:update(dt)
for k, p in pairs(plateforms) do
p:update(dt)
if p.y > camera.y + 480/2 then
table.remove(plateforms, k)
end
end
print(table.getn(plateforms))
end
function generate(from, to)
for i = from/30 + 1, to/30 do
x = math.random(0, 20)
if x >= 3 and x <= 20 then table.insert(plateforms, Plateform:new(math.random(0 + 50, 320 - 50), - i*30 + 480)) end
end
end
--function love.sensorchanged(n,t,v)
-- acc = -tonumber(v[1])
--end
function love.draw()
love.graphics.draw(background1,0,0)
love.graphics.draw(background2,0,0)
camera:set()
for _, p in pairs(plateforms) do
p:draw()
end
c:draw()
camera:unset()
love.graphics.print(-camera.y + 480/2, 10, 10)
end