-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.lua
More file actions
101 lines (63 loc) · 1.47 KB
/
game.lua
File metadata and controls
101 lines (63 loc) · 1.47 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
require("key_handle")
require("renderer.renderer")
require("states.game_states")
sample_state=require("states.state_sample")
local game ={}
---------------------------
--preinit functions?
---------------------------
local base={}
------------------------------------------------------------
--Base data fields
------------------------------------------------------------
constants = nil
------------------------
-- dynamic data
--game state
game_state = GameStates.MAIN_MENUE
previous_game_state = game_state
--others
key_timer = 0--timer between movement
mouse_coords={0,0}
exit_timer =0
selector_timer = 0
target_timer = 0
-----------------------------------------------------------
-- special data fields for debugging / testing only
-----------------------------------------------------------
--loading a game
function game.load()
game_state = GameStates.PLAYING
game.new()
end
--new game
function game.new()
sample_state:startup()
end
function game.play(dt)
sample_state:update()
end
--main loop
function game.update(dt)
--handle game stuff
game.play(dt)
glib.ui.update()
end
function game.draw()
sample_state:draw()
glib.ui.draw()
end
function game.keyHandle(key,s,r,pressed_)
if pressed_ == true then
key_list[key] = true
last_key=key
else
key_list[key] = nil
end
end
function game.MouseHandle(x,y,btn)
end
function game.MouseMoved(mx,my)
mouse_coords={mx,my}
end
return game