-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.lua
More file actions
86 lines (62 loc) · 2.5 KB
/
Copy pathmain.lua
File metadata and controls
86 lines (62 loc) · 2.5 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
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
-- load the composer
local composer = require( "composer" )
-- load the audio module
local audioMod = require( "scenes.libs.audio" )
-- load physics module
local physics = require( "physics" )
-- trigger the first start of the engine
-- (it will be stopped in the create phase of each module and then restarted in the show phase)
physics.start()
-- hide status bar
display.setStatusBar( display.HiddenStatusBar )
-- seed the random number generator
math.randomseed( os.time() )
-- set default font params on the composer
local fontParams = {}
fontParams.path = "fonts/AlloyInk"
fontParams.colorR = 0.98
fontParams.colorG = 0.69
fontParams.colorB = 0.23
fontParams.colorR2 = 0.9
fontParams.colorG2 = 0.5
fontParams.colorB2 = 0.1
composer.setVariable( "defaultFontParams", fontParams )
-- fading times for windows
composer.setVariable( "windowFadingOpenTime", 400 )
composer.setVariable( "windowFadingClosingTime", 200 )
-- version of the game
composer.setVariable( "version", "1.0.1" )
-- reserve channel 1 for background music
audio.reserveChannels( 1 )
-- set the audio from a save
audioMod.setFromSave()
-- @DEBUG -----------------------------------------------------------------------------------------
local debugMode = false
-- monitor Memory Usage
local function printMemUsage()
local memUsed = (collectgarbage("count"))
local texUsed = system.getInfo( "textureMemoryUsed" ) / 1048576 -- Reported in Bytes
print("\n---------MEMORY USAGE INFORMATION---------")
print("System Memory: ", string.format("%.00f", memUsed), "KB")
print("Texture Memory:", string.format("%.03f", texUsed), "MB")
print("------------------------------------------\n")
end
-- collect garbage and then print memory usage
local function collectAndPrint()
collectgarbage("collect")
printMemUsage()
end
-- only load monitor if running in simulator and debugMode is active
if (system.getInfo("environment") == "simulator" and debugMode == true) then
--Runtime:addEventListener( "enterFrame", printMemUsage) -- print memory usage for every frame
-- continuosly print mem and launch garbage collector
timer.performWithDelay(4000, collectAndPrint, 0)
end
-- ------------------------------------------------------------------------------------------------
-- Go to the menu screen
composer.gotoScene( "scenes.menu" )