]> Untitled Git - lightcycles-love.git/blob - main.lua
e6fe8fbe412e8560781e1bf7d3ceaa234d8ee83c
[lightcycles-love.git] / main.lua
1 -- main
2
3 require 'player'
4
5 function love.load()
6     player = Player:new({position={x=100, y=100}})
7 end
8
9 function love.draw()
10     -- set bg
11     local bgcolor = {0.2, 0.2, 0.5}
12     love.graphics.setBackgroundColor(bgcolor)
13
14     -- draw basic grid
15     love.graphics.setColor(0.3, 0.3, 0.6)
16     local width = love.graphics.getWidth()
17     local height = love.graphics.getHeight()
18     local delta = 50
19
20     for x=0,width,delta do
21         love.graphics.line(x, 0, x, height)
22     end
23
24     for y=0,height,delta do
25         love.graphics.line(0, y, width, y)
26     end
27
28     -- misc
29     player:draw()
30 end
31
32 function love.update(dt)
33     if love.keyboard.isDown('escape') then
34         love.event.quit()
35     end
36     player:update(dt)
37 end
38
39 function love.quit()
40     print('Thanks for playing!')
41     print('Recorded ' .. #player.path / 2 .. ' player path points')
42 end