diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3666da1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +2048_qt.pro.user diff --git a/README.md b/README.md new file mode 100644 index 0000000..bab877a --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# 2048-Qt +A clone of [2048](https://github.com/gabrielecirulli/2048), implemented in Qt. diff --git a/qml/main.qml b/qml/main.qml index 11d6ff4..feaa289 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -2,6 +2,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 import QtQuick.Dialogs 1.1 +import QtQuick.Window 2.1 import "2048.js" as MyScript ApplicationWindow { @@ -10,29 +11,31 @@ ApplicationWindow { height: 730 title: qsTr("2048 Game"); - Rectangle { - anchors.fill: parent - - Item { - id: helper - property var myColors: {"bglight": "#FAF8EF", - "bggray": Qt.rgba(238/255, 228/255, 218/255, 0.35), - "bgdark": "#BBADA0", - "fglight": "#EEE4DA", - "fgdark": "#776E62", - "bgbutton": "#8F7A66", // Background color for the "New Game" button - "fgbutton": "#F9F6F2" // Foreground color for the "New Game" button - } + x: (Screen.width - width) / 2 + y: (Screen.height - height) / 2 + + Item { + id: helper + property var myColors: {"bglight": "#FAF8EF", + "bggray": Qt.rgba(238/255, 228/255, 218/255, 0.35), + "bgdark": "#BBADA0", + "fglight": "#EEE4DA", + "fgdark": "#776E62", + "bgbutton": "#8F7A66", // Background color for the "New Game" button + "fgbutton": "#F9F6F2" // Foreground color for the "New Game" button } + } + color: helper.myColors.bglight + + Item { + anchors.fill: parent + anchors.margins: 30 - color: helper.myColors.bglight focus: true Keys.onPressed: MyScript.moveKey(event) Text { id: gameName - x: 30 - y: 30 font.pixelSize: 55 font.bold: true text: "2048" @@ -40,9 +43,7 @@ ApplicationWindow { } Row { - y: 30 anchors.right: parent.right - anchors.rightMargin: 30 spacing: 5 Repeater { id: scoreBoard @@ -74,8 +75,7 @@ ApplicationWindow { Text { id: banner - x: 30 - y: 120 + y: 90 height: 40 text: "Join the numbers and get to the 2048 tile!" color: helper.myColors.fgdark @@ -86,9 +86,8 @@ ApplicationWindow { Button { width: 129 height: 40 - y: 120 + y: 90 anchors.right: parent.right - anchors.rightMargin: 30 style: ButtonStyle { background: Rectangle { @@ -107,8 +106,7 @@ ApplicationWindow { } Rectangle { - x: 30 - y: 200 + y: 170 width: 500 height: 500 color: helper.myColors.bgdark