-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.qml
111 lines (101 loc) · 2.58 KB
/
main.qml
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
import QtQuick 1.1
import "scripts/game.js" as Game
Rectangle {
id: mainWindow
width: 400
height: width/canvas.xCount*canvas.yCount
color: "black"
property int score: 0
property int level: 0
onLevelChanged: {
if(!Game.isBotPlaying) {
levelText.text = "Level: " + level;
}
}
Item {
id: canvas
anchors.fill: parent
z: 0
property int xCount: 10
property int yCount: 22
signal right
signal left
signal down
signal rotate
Component.onCompleted: Game.startGame();
focus: true
Keys.onRightPressed: right();
Keys.onLeftPressed: left();
Keys.onDownPressed: down();
Keys.onUpPressed: rotate();
Keys.onSpacePressed: Game.changePauseMode();
onRight: Game.action("right");
onLeft: Game.action("left");
onDown: Game.action("down");
onRotate: Game.action("rotate");
Timer {
id: timer
interval: 1000
running: false
repeat: true
onTriggered: Game.nextStep();
}
Timer {
id: levelTimer
interval: 60000
running: true
repeat: true
onTriggered: {
level++;
timer.interval=1000/(Math.pow(1.25, level));
}
}
Timer {
id: botTimer
interval: 1
repeat: true
triggeredOnStart : true
onTriggered: {
if(Game.commandsArray[0])
(Game.commandsArray.shift())();
else
Game.action("down");
}
}
}
Menu{
id: menu
anchors.fill: parent
visible: false
onNewGame: Game.restartGame();
onExit: Qt.quit();
onContinueGame: Game.changePauseMode();
onBotOn: {
levelText.text = "Bot";
Game.runAIGame();
}
onBotOff: {
levelText.text = "Level: " + level;
Game.runPlayerGame();
}
onChangeLevel: {
Game.changeLevel(sign);
menuArea.levelString = "Level: " + String(Game.levelArray[Game.currentLevelIterator]);
}
}
Text {
id: levelText
color: "#ffffff"
z: 5
text: "Level: " + level
font.pointSize: 16
}
Text {
id: scoreText
anchors.top: levelText.bottom
color: "#ffffff"
z: 5
text: "Score: " + score
font.pointSize: 16
}
}