forked from ruilov/CargoBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.lua
78 lines (64 loc) · 2.02 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
76
77
78
-- Main.lua
supportedOrientations(PORTRAIT_ANY)
DEV_MODE = true
NO_MUSIC = false
function setup()
IO.init()
--IO.clearAll()
--IO.printSolution("Mirror 3")
displayMode(FULLSCREEN)
if not DEV_MODE then displayMode(FULLSCREEN_NO_BUTTONS) end
watch("dt")
elapsedTimes = {}
sounds = Sounds()
checkLevelOrder()
if IO.readMusicState() == false then GLOBAL_MUTE = true end
end
function draw()
dt = DeltaTime*100
-- estimate DeltaTime based on last few observations to pass to sound library
table.insert(elapsedTimes,ElapsedTime)
while #elapsedTimes > 50 do table.remove(elapsedTimes,1) end
MY_DELTA_TIME = (elapsedTimes[#elapsedTimes] - elapsedTimes[1]) / (#elapsedTimes - 1)
background()
if not currentScreen then
currentScreen = MenuScreen()
--currentScreen = SplashScreen()
--currentScreen = Level(levels[39])
--currentScreen:addTutorial()
currentScreen:bind()
transitionScreen = TransitionScreen() -- global variable
end
currentScreen:draw()
currentScreen:tick()
Tweener.run()
--ShakeDetector.check() -- do we want to keep this?
if currentMusic and not GLOBAL_MUTE then currentMusic:play() end
end
function touched(t)
if currentScreen and currentScreen.touched then currentScreen:touched(t) end
end
function collide(contact)
if currentScreen and currentScreen.collide then currentScreen:collide(contact) end
end
function keyboard(key)
if currentScreen and currentScreen.keyboard then currentScreen:keyboard(key) end
end
function printout(msg,x,y)
fill(255,255,255,255)
fontSize(40)
textMode(CORNER)
text(msg,x,y)
end
function checkLevelOrder()
for p = 1,6 do
local pack = packs[p]
for i = 1,6 do
local level = levels[(p-1)*6+i]
local n1 = level.name
local n2 = pack.levels[i]
assert(n1==n2,"level order is wrong "..p.." "..i..
"\n-"..n1.."-\n-"..n2.."-")
end
end
end