-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
104 lines (84 loc) · 2.39 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
-- Class.lua Copyright (c) 2010-2013 Matthias Richter
Class = require 'class'
-- push.lua Copyright (c) 2018 Ulysse Ramage
push = require 'push'
require 'Animation'
require 'Fireball'
require 'Frostray'
require 'Items'
require 'Map64'
require 'Map'
require 'Wizard'
require 'Books'
-- Screen window global variables / virtutal sizes enables easy scaling
SCALE = 2.5
WINDOW_WIDTH = 1920
WINDOW_HEIGHT = 1080
VIRTUAL_WIDTH = WINDOW_WIDTH / SCALE
VIRTUAL_HEIGHT = WINDOW_HEIGHT / SCALE
-- WIZARD SPAWN TILE
SPAWNX = 29.5
SPAWNY = 29
love.graphics.setDefaultFilter('nearest', 'nearest')
defaultfont = love.graphics.getFont()
fancyfont = love.graphics.newFont('master_fonts/CaviarDreams.ttf', 12)
nicefont = love.graphics.newFont('master_fonts/Oswald-Regular.ttf', 12)
map = Map()
-- initialisation of objects and data
function love.load()
love.window.setTitle('Wizard Quest')
push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
fullscreen = false,
vsync = true,
resizable = true
})
love.keyboard.keysPressed = {}
love.keyboard.keysReleased = {}
love.mouse.setVisible(false)
love.mouse.setRelativeMode(false)
end
function love.resize(w, h)
push:resize(w, h)
end
-- global key pressed function
function love.keyboard.wasPressed(key)
if (love.keyboard.keysPressed[key]) then
return true
else
return false
end
end
-- -- global key released function
function love.keyboard.wasReleased(key)
if (love.keyboard.keysReleased[key]) then
return true
else
return false
end
end
-- called whenever a key is pressed
function love.keypressed(key)
if key == 'escape' then
love.event.quit()
end
love.keyboard.keysPressed[key] = true
end
-- -- called whenever a key is released
function love.keyreleased(key)
love.keyboard.keysReleased[key] = true
end
-- called every frame, with dt passed in as delta in time since last frame
function love.update(dt)
map:update(dt)
-- reset all keys pressed and released this frame
love.keyboard.keysPressed = {}
love.keyboard.keysReleased = {}
end
-- called each frame, used to render to the screen
function love.draw()
push:apply('start')
love.graphics.translate(math.floor(-map.camX + 0.5), math.floor(-map.camY + 0.5))
love.graphics.clear(168/255, 154/255, 154/255, 1)
map:render()
push:apply('end')
end