-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
46 lines (33 loc) · 803 Bytes
/
main.lua
File metadata and controls
46 lines (33 loc) · 803 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
39
40
41
42
43
44
45
46
require('purple')
function love.load()
scale = 5
love.graphics.setBackgroundColor(32, 32, 32)
player = Purple:new()
player:init(love.graphics.getWidth()/scale, love.graphics.getHeight()/scale)
tick = 0
end
function love.focus(f) running = f end
function love.draw()
love.graphics.print(love.timer.getFPS(), 0, 0)
love.graphics.scale(scale)
player:draw()
end
function love.update(dt)
if not running then return end
tick = tick + 1
if tick < 2 then return end
tick = 0
player:update(dt, love.graphics.getWidth()/scale, love.graphics.getHeight()/scale)
end
function love.keypressed(key)
player:keypressed(key)
if key == 'escape' then
love.event.push('quit')
end
if key == ' ' then
running = not running
end
end
function love.keyreleased(key)
player:keyreleased(key)
end