-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.lua
67 lines (49 loc) · 1.4 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Object = require "lib.classic"
CHUNK_SIZE = 16
CHUNK_HEIGHT = 48
local Player = require "src.player"
_debug = {}
function debug(...)
local vars = {...}
local str = ""
for i = 1, #vars do
str = str .. tostring(vars[i]) .. " "
end
table.insert(_debug, str)
end
function love.mousemoved(x, y, dx, dy)
player:updateDirection(dx, dy)
end
function love.mousepressed(x, y, button)
player:handlePress(x, y, button)
end
function love.keypressed(key)
if key == "escape" then love.event.quit() end
if key == "f3" then love.window.setFullscreen(not love.window.getFullscreen()) end
if key == "f2" then love.graphics.captureScreenshot(os.time() .. ".png") end
if key == "k" then world:save() end
end
function love.load()
love.mouse.setRelativeMode(true)
love.graphics.setDefaultFilter("nearest", "nearest")
tileset = love.graphics.newImage("tileset.png")
love.filesystem.setIdentity("lunarcraft")
love.graphics.setBackgroundColor(135 / 255, 206 / 255, 233 / 255)
local World = require "src.world"
world = World:new()
player = Player(world)
end
function love.update(dt)
_debug = {}
player:update(dt)
world:update(dt)
end
function love.draw()
player:draw()
local w, h = love.graphics.getDimensions()
love.graphics.circle("fill", w / 2, h / 2, 2)
debug("FPS:", love.timer.getFPS())
for i, v in ipairs(_debug) do
love.graphics.print(v, 10, 10 + (i - 1) * 20)
end
end