-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfallingBlocks.qml
More file actions
178 lines (144 loc) · 3.97 KB
/
fallingBlocks.qml
File metadata and controls
178 lines (144 loc) · 3.97 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import QtQuick 2.4
import Ubuntu.Components 1.2
import QtMultimedia 5.4
import "gui"
import "logic/game.js" as Game
MainView {
width: units.gu(50)
height: units.gu(80)
headerColor: UbuntuColors.darkAubergine
backgroundColor: UbuntuColors.midAubergine
footerColor: UbuntuColors.warmGrey
focus: true
applicationName: "com.ubuntu.developer.labsin.fallingblocks"
automaticOrientation: false
QtValues {
id: values
onGameOverChanged: {
if(gameOver) {
}
}
}
property var musicFiles: ["01.mp3", "02.mp3", "03.mp3"]
Audio {
id: soundtrack
autoPlay: true
property int current: Math.floor((Math.random() * musicFiles.length) + 1);
onCurrentChanged: if(current> musicFiles.length) current = 1
source: "music/"+musicFiles[current-1]
onStatusChanged: {
if(status == Audio.EndOfMedia) {
current+=1
}
}
volume: values.musicVolume/10
}
Item {
id: fx
property var clear4: SoundEffect {
id: clear4Fx
source: "fx/clear.wav"
volume: values.fxVolume/10
}
property var clear1: SoundEffect {
id: clear1Fx
source: "fx/clear1.wav"
volume: values.fxVolume/10
}
property var alert: SoundEffect {
id: alertFx
source: "fx/alert.wav"
volume: values.fxVolume/10
}
property var fastdrop: SoundEffect {
id: fastDropFx
source: "fx/fastdrop.wav"
volume: values.fxVolume/10
}
property var laser: SoundEffect {
id: laserFx
source: "fx/laser.wav"
volume: values.fxVolume/10
}
property var powerup: SoundEffect {
id: powerUpFx
source: "fx/powerup.wav"
volume: values.fxVolume/10
}
property var shutdown: SoundEffect {
id: shutdownFx
source: "fx/shutdown.wav"
volume: values.fxVolume/10
}
property var turn: SoundEffect {
id: turnFx
source: "fx/turn.wav"
volume: values.fxVolume/10
}
property var blip: SoundEffect {
id: turn2Fx
source: "fx/blip.wav"
volume: values.fxVolume/10
}
}
Connections {
target: mainDbObj
onHighScoreChanged: {
if(values.debug)
print("HighscoreChanged"+mainDbObj.highScore.score)
values.highscore = mainDbObj.highScore.score
}
}
Database {
id:mainDbObj
}
PageStack {
id: stack
Component.onCompleted: push(tabs)
Tabs {
id: tabs
visible: false
Tab {
title: i18n.tr("FallingBlocks")
page: BlocksPage {
id: gamePage
}
}
Tab {
title: i18n.tr("Highscores")
page: HighscorePage {
id: highscorePage
}
}
onCurrentPageChanged: {
if(currentPage!=1 && values.running==true) {
values.paused = true;
}
}
}
onCurrentPageChanged: {
if(currentPage!=1 && values.running==true) {
values.paused = true;
}
}
SettingPage {
id: settingPage
title: i18n.tr("Settings")
visible: false
}
}
Connections {
target: Qt.application
onActiveChanged:
if(!Qt.application.active && values.running) {
values.paused = true
}
}
Component.onCompleted: {
Game.valuesObject = values;
Game.fx = fx
gamePage.init()
Keys.forwardTo = values.gameCanvas
Game.init();
}
}