Select Git revision
-
Breitwiller Josephine authoredBreitwiller Josephine authored
Main.qml 3.83 KiB
import QtQuick
Window {
visible: true
width: 400
height: 600
title: qsTr("Application 2048")
Text {
text: "Fusionnez les nombres pour atteindre 2048!"
font.bold: true
color:"grey"
anchors.horizontalCenter: parent.horizontalCenter
y:145
}
Rectangle{
width:105;height:105
color:"orange"
x:35
y:10
radius:4
Text {
text:"2048"
color: "white"
font.bold: true
font.pixelSize: 30
anchors.centerIn: parent
}
}
Rectangle{
color:"grey"
width: 90; height: 90
x:270
y:10
radius:5
Text{
text: "MEILLEUR"
color:"lightgrey"
font.pixelSize: 14
font.bold: true
anchors.horizontalCenter: parent.horizontalCenter
y:10
}
Text{
id: bestScore
text:"0"
color:"white"
font.bold: true
font.pixelSize: 25
anchors.centerIn:parent
}
}
Rectangle{
color:"grey"
width: 90; height: 90
x:170
y:10
radius:5
Text{
text: "SCORE"
color:"lightgrey"
font.pixelSize: 14
font.bold: true
anchors.horizontalCenter: parent.horizontalCenter
y:10
}
Text{
id: score
text:"0"
color:"white"
font.bold: true
font.pixelSize: 25
anchors.centerIn:parent
}
}
Rectangle {
id: buttonNew
color:"#F65E3B"
width: 90; height: 30
x:170
y:105
radius:5
Text{
id: buttonLabel
anchors.centerIn: parent
text: "NOUVEAU "
color:"white"
font.bold: true
}
MouseArea{
id: buttonMouseArea
anchors.fill: parent //anchor all sides of the mouse area to the rectangle's anchors
//onClicked handles valid mouse button clicks
onClicked: gameManager.restartGame()
}
}
Rectangle {
id: undo
color: "#F65E3B"
width: 90; height: 30
x:270
y:105
radius:5
Text{
anchors.centerIn: parent
text: "ANNULER "
color:"white"
font.bold: true
}
MouseArea{
id: undoMouseArea
anchors.fill: parent //anchor all sides of the mouse area to the rectangle's anchors
//onClicked handles valid mouse button clicks
onClicked: gameManager.undo()
}
}
Rectangle{
width:350; height:350
anchors.horizontalCenter: parent.horizontalCenter
y:170
color:"grey"
radius: 10
Grid {
id: gameGrid
columns: 4
rows: 4
anchors.centerIn: parent
spacing: 8
padding:8
Repeater {
model: 16
Rectangle {
width: 78
height: 78
color: "lightgrey"
radius:10
Text {
anchors.centerIn: parent
text: ""
}
}
}
}
}
Item{
id: keyHandler
focus: true
Keys.onPressed: {
if (event.key === Qt.Key_Left) gameManager.moveLeft();
else if (event.key === Qt.Key_Right) gameManager.moveRight();
else if (event.key === Qt.Key_Up) gameManager.moveUp();
else if (event.key === Qt.Key_Down) gameManager.moveDown();
}
}
}