-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.lua
82 lines (73 loc) · 2.29 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
79
80
81
82
-- Copyright 2013 Arman Darini
display.setStatusBar(display.HiddenStatusBar)
-- these are used almost everywhere, so make they global
_utils = require("lib.utils")
_math = require("lib.math2")
_helpers = require("lib.helpers")
_widget = require("widget")
_storyboard = require("storyboard")
_storyboard.purgeOnSceneChange = true
_game = {
debug = false,
w = display.contentWidth,
h = display.contentHeight,
centerX = display.contentCenterX,
centerY = display.contentCenterY,
font = "AveriaLibre-Bold",
moveSensitivity = 100,
controlsBlocked = false,
achievements = { "Not Bad!", "Rockin' It!", "On Steroids!", "Unbelievable!", "Divine!" },
exp = { 0, 100, 200, 400, 800, 1600, 3200, 6400, 12800 },
level = 1,
levelCompleted = false,
levels = {
{ stars = { 2, 3, 4 },
},
},
score = 0,
}
-- init player
local playerDefaults = {
soundVolume = 0.3,
musicVolume = 1,
exp = 0,
credits = 100,
currentLevel = 1,
levels = {
{ attempts = 0, highScore = 0 },
{ attempts = 0, highScore = 0 },
{ attempts = 0, highScore = 0 },
{ attempts = 0, highScore = 0 },
{ attempts = 0, highScore = 0 },
{ attempts = 0, highScore = 0 },
{ attempts = 0, highScore = 0 },
{ attempts = 0, highScore = 0 },
{ attempts = 0, highScore = 0 },
},
version = 4,
}
_player = _utils.loadTable("player")
if nil == _player or _player.version ~= playerDefaults.version then
_player = playerDefaults
_utils.saveTable("player")
end
_utils.printTable(player)
-- init sounds and music
_sounds = {
click = audio.loadSound("sounds/scenes/click.mp3"),
rescue_radical = audio.loadSound("sounds/scenes/play_level/rescue_radical2.mp3"),
catch_radical = audio.loadSound("sounds/scenes/play_level/catch_radical.mp3"),
place_radical = audio.loadSound("sounds/scenes/play_level/place_radical.mp3"),
remove_vertex = audio.loadSound("sounds/scenes/play_level/remove_vertex.mp3"),
reach_exit = audio.loadSound("sounds/scenes/play_level/reach_exit.mp3"),
}
audio.setVolume(_player.soundVolume, { channel = 1 }) --sfx
audio.setVolume(_player.musicVolume, { channel = 2 }) --music
--music = audio.loadStream("sounds/theme_song.mp3")
--audio.play(music, { channel = 2, loops=-1, fadein=1000 })
-- add debug
if _game.debug then
timer.performWithDelay(1000, _utils.printMemoryUsed, 0)
end
-- start game
_storyboard.gotoScene("scenes.main_menu")