-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.qml
95 lines (85 loc) · 2.24 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
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.3
Window {
id: window
width: 640
height: 480
visible: true
color: "#191928"
title: qsTr("Monster slayer")
ColumnLayout {
anchors {
fill: parent
leftMargin: 10
rightMargin: 10
topMargin: 10
bottomMargin: 10
}
Text{
text: qsTr("Player")
font.pixelSize: 25
color: "white"
}
ProgressBar{
id: playerProgressBar
from: 0
to: 100 // max value
Layout.fillWidth: true
value: backend.playerBar
}
Text{
text: qsTr("Monster")
font.pixelSize: 25
color: "white"
}
ProgressBar{
id: monsterProgressBar
from: 0
to: 100 // max value
Layout.fillWidth: true
value: backend.monsterBar;
}
Button{
visible: !backend.gameOver
text: qsTr("Attack")
Layout.alignment: horizontalCenter
font.pixelSize: 20
Layout.fillWidth: true
onClicked: {
backend.attack()
}
}
Button{
visible: !backend.gameOver
text: qsTr("Heal")
Layout.alignment: horizontalCenter
font.pixelSize: 20
Layout.fillWidth: true
enabled: backend.healEnabled
onClicked: {
backend.heal()
}
}
Button{
visible: backend.gameOver
text: qsTr("Play again")
Layout.alignment: horizontalCenter
font.pixelSize: 20
Layout.fillWidth: true
onClicked: {
backend.playAgain()
}
}
Text{
visible: backend.gameOver
text: backend.winner == "player" ? "YOU WIN" : "GAME OVER"
font.pixelSize: 25
horizontalAlignment: Text.AlignHCenter
Layout.alignment: horizontalCenter
Layout.fillWidth: true
color: backend.winner == "player" ? "green": "red"
}
}
}