-
Notifications
You must be signed in to change notification settings - Fork 0
/
reversi.qml
68 lines (58 loc) · 1.68 KB
/
reversi.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
import QtQuick 2.9
Rectangle {
width: grid.width + 20
height: column.height + 20
gradient: Gradient {
GradientStop {
position: 0
color: "#977568"
}
GradientStop {
position: 1
color: "#3a240b"
}
}
Column {
id: column
anchors.centerIn: parent
width: grid.width
Row {
anchors.left: parent.left
anchors.right: parent.right
height: childrenRect.height
PlayerStats {
id: player1
width: parent.width / 2
playerColor: "black"
playerName: "Player 1"
squareCount: grid.blackSquares
currentPlayer: grid.turn == playerColor
}
PlayerStats {
id: player2
width: parent.width / 2
playerColor: "white"
playerName: "Player 2"
squareCount: grid.whiteSquares
currentPlayer: grid.turn == playerColor
}
}
GameGrid {
id: grid
anchors.left: parent.left
// columns need to be even
columns: 8
// rows need to be even
rows: 8
Component.onCompleted: {
var midRow = rows / 2;
var midCol = columns / 2;
square(midRow, midCol).state = "white";
square(midRow-1, midCol-1).state = "white";
square(midRow-1, midCol).state = "black";
square(midRow, midCol-1).state = "black";
updateStats();
}
}
}
}