-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
57 lines (44 loc) · 1.36 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
-- slidetoattack main
local Game = require "game"
local Renderer = require "rendering.renderer"
local FSM = require "fsm"
local stage_representation;
local stage_size = 5
local number_of_friendlies = 7
local number_of_enemies = 7
function love.load()
love.window.setMode(800, 480, {resizable = false, msaa = 4})
math.randomseed(os.time())
Game.init(stage_size, number_of_friendlies, number_of_enemies)
Renderer.init(stage_size)
for index, gameoperator in pairs(Game.representation) do
local game_coords = Game.index_to_game(index)
Renderer.add_operator(
gameoperator.id,
gameoperator.is_friendly,
game_coords
)
Renderer.add_arrowtile(gameoperator.id, gameoperator.is_friendly, game_coords)
end
-- Pass the above Game and Renderer instances to all states
FSM.init(Game, Renderer)
FSM.change_state(FSM.states.IdleState) -- First state is Idle
end
function love.update(dt)
FSM.update_state(dt)
Renderer.update_operators(dt)
end
function love.draw()
-- Fix screen centre to (0, 0)
love.graphics.translate(love.graphics.getWidth() / 2, love.graphics.getHeight() / 2)
FSM.draw_state(0)
-- Draw Background lines
Renderer.draw_background()
FSM.draw_state(1)
-- Draw stage
Renderer.draw_stage_tiles()
FSM.draw_state(2)
-- Draw operators
Renderer.draw_operators_arrowtiles()
FSM.draw_state(3)
end