-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
32 lines (24 loc) · 792 Bytes
/
main.lua
File metadata and controls
32 lines (24 loc) · 792 Bytes
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
local composer = require("composer")
local json = require("json")
local scoresTable = {}
local filePath = system.pathForFile("scores.json", system.DocumentsDirectory)
-- hide status bar
display.setStatusBar(display.HiddenStatusBar)
-- seed the random number generator
math.randomseed(os.time())
-- reserve channel 1 for bgm
audio.reserveChannels(1)
-- reduce overall volume of channel
audio.setVolume(0, {channel=1})
-- go to menu screen
composer.gotoScene("menu")
local file = io.open(filePath, "r")
if file then
local contents = file:read("*a")
io.close(file)
scoresTable = json.decode(contents)
end
if(scoresTable == nil or #scoresTable == 0) then
scoresTable = { 10000, 7500, 5200, 4700, 3500, 3200, 1200, 1100, 800, 500 }
end
composer.setVariable("highScore", scoresTable[1])