forked from TomK32/Unstack2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.moon
60 lines (47 loc) · 1.51 KB
/
main.moon
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
--
-- Unstack2 main.lua
require 'lib.game_analytics'
require 'block'
require 'highscores'
GameAnalytics.newEventWithoutDelay = GameAnalytics.newEvent
GameAnalytics.newEvent = (category, ...) ->
opts = ...
timer.performWithDelay 1, ->
analytics.newEventWithoutDelay(category, opts)
export analytics = GameAnalytics
analytics.isDebug = false
analytics.submitSystemInfo = true
analytics.archiveEvents = true
analytics.init(require('conf.analytics'))
-- log events
analytics.newEvent("design", {event_id: "loading"})
block_size = math.floor(display.contentWidth / 10 / 8) * 8
export game = {
-- apply /8*8 on block size to get nicer numbers
block_size: block_size,
level: 0,
lvlString: ->
string.format('%4.i', game.level)
score: 0,
running_score: 0, -- to increase the score with some easing
width: math.floor(display.contentWidth / block_size)
height: math.floor(display.contentHeight / block_size) - 4
highscores: Highscores()
field: nil,
gestureBlock: Block({}),
targetBlock: nil,
last_target_time: 0,
sounds: require('sounds')
getTimeRemaining: (now) ->
return now + math.ceil(3 * math.sqrt(game.field\width() * game.field\height()) / 30) * 30000
reset: ->
game.running = true
game.running_score = game.score
game.score_level_start = game.score
game.time_remaining = nil
game.last_target_time = nil
}
display.setStatusBar( display.HiddenStatusBar )
export storyboard = require "storyboard"
storyboard.purgeOnSceneChange = true
storyboard.gotoScene("scenes.intro")