-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathselectiveFunctionality.lua2p
70 lines (52 loc) · 1.64 KB
/
selectiveFunctionality.lua2p
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
--[[============================================================
--=
--= LuaPreprocess example: Selective functionality.
--=
--= Here we decide what code should be included and run in the
--= final program with some flags set in the metaprogram.
--=
--============================================================]]
!ENABLE_CONSOLE = true
!INCLUDE_TEST_LEVELS = false
quitGame = false
function addNormalLevelsToArray(levels) print("Adding normal levels") end
function addTestLevelsToArray(levels) print("(*) Adding test levels") end
function getPlayableLevels()
local levels = {}
addNormalLevelsToArray(levels)
!if INCLUDE_TEST_LEVELS then
addTestLevelsToArray(levels)
!end
return levels
end
function loadAssets() print("Loading assets") end
function showLevelsToPlayer(levels) print("Showing levels to player") end
function readInput() print("Reading input") end
function updateGameState() print("Updating game state") end
function render() print("Rendering") end
!if ENABLE_CONSOLE then
function initConsole() print("(*) Initting console") end
function updateConsole() print("(*) Updating console") end
!end
function runGame()
print("Starting game")
loadAssets()
!if ENABLE_CONSOLE then
initConsole()
!end
local levels = getPlayableLevels()
showLevelsToPlayer(levels)
-- Main game loop.
repeat
readInput()
!if ENABLE_CONSOLE then
updateConsole()
!end
updateGameState()
render()
-- In this example, don't run the loop forever!
quitGame = true
until quitGame
print("Quitting game")
end
runGame()