-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
77 lines (53 loc) · 1.33 KB
/
main.lua
File metadata and controls
77 lines (53 loc) · 1.33 KB
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
-- SimpleShooter for CS/IMGD 4100
-- by Terry Hearst and Kyle Reese
-- Define fonts for later use
titleFont = love.graphics.newFont(72)
bigFont = love.graphics.newFont(36)
mediumFont = love.graphics.newFont(24)
smallFont = love.graphics.newFont(16)
-- Helper library
require "helper"
require "agentHelper"
require "commonActions"
-- Include all the game states
states = {}
require "states/game"
require "states/menu"
-- Include all objects
objects = {}
require "objects/player"
require "objects/bullet"
require "objects/ammoPack"
-- Include all AI agents
agents = {}
require "agents/doNothing"
require "agents/spinInCircles"
require "agents/spinAndShoot"
require "agents/human"
require "agents/dodgeOnly"
require "agents/decision"
require "agents/decisionSmart"
-- Main game callbacks
function love.load()
state = states.menu.load()
end
function love.update(dt)
-- If the game lags or is getting less than 20 fps, make the game ticks lag behind
if dt > 1/20 then dt = 1/20 end
if state and state.update then
state:update(dt)
end
end
function love.draw()
if state and state.draw then
state:draw()
end
end
-- Pass through other callbacks
for _, v in ipairs{"keypressed", "keyreleased", "mousemoved", "mousepressed", "mousereleased"} do
love[v] = function(...)
if state and state[v] then
state[v](state, ...)
end
end
end