-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
75 lines (61 loc) · 1.82 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
--[[
Base main.lua for a Love2D project
@author Saverton
]]
local love = love or {}
love.graphics.setDefaultFilter('nearest', 'nearest')
require 'src/Dependencies'
-- load the game
function love.load()
love.window.setTitle('Random RPG')
math.randomseed(os.time())
LibPush:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
fullscreen = false,
vsync = true,
resizable = true
})
gStateStack = StateStack()
gStateStack:push(StartState())
-- helps start game faster for testing
gStateStack:push(WorldState({debug = true}))
love.keyboard.keysPressed = {}
love.keyboard.setTextInput(false)
mouseWheelMovement = {
x = 0,
y = 0
}
inputtext = ''
end
-- resize screen
function love.resize(w, h)
LibPush:resize(w, h)
end
-- add a key to the table of keys pressed this frame
function love.keypressed(key)
love.keyboard.keysPressed[key] = true
end
-- return true if this key was pressed this frame
function love.keyboard.wasPressed(key)
return love.keyboard.keysPressed[key]
end
-- set mouse wheel movement according to movement this frame
function love.wheelmoved(x, y)
mouseWheelMovement.x, mouseWheelMovement.y = x, y
end
-- return the y axis mouse wheel movement
function GetYScroll()
return mouseWheelMovement.y
end
-- update the game
function love.update(dt)
Timer.update(dt) -- update the timer
gStateStack:update(dt) -- update the current state of the game
love.keyboard.keysPressed = {} -- reset the keys pressed table
mouseWheelMovement.x, mouseWheelMovement.y = 0, 0 -- reset mouse scroll
end
-- render the game this frame
function love.draw()
LibPush:start()
gStateStack:render()
LibPush:finish()
end