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