Skip to content
Snippets Groups Projects
Commit 28ef7084 authored by Breitwiller Josephine's avatar Breitwiller Josephine
Browse files

page menu

ajout de la page menu avec stackview pour la gestion des pages
parent dad5730c
Branches
No related tags found
No related merge requests found
......@@ -16,10 +16,11 @@ qt_add_qml_module(appapplicationQT2048
URI applicationQT2048
VERSION 1.0
QML_FILES
Main.qml
QML_FILES MonElement.qml
GamePage.qml
QML_FILES MenuPage.qml
SOURCES gamemanager.h gamemanager.cpp
SOURCES gamemanager.h gamemanager.cpp
QML_FILES Main.qml
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
......
import QtQuick
import QtQuick.Controls
Rectangle {
width: 400
height: 600
color: "#FAF8EF"
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
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
onClicked: gameManager.undo()
}
}
Rectangle{
width:350; height:350
anchors.horizontalCenter: parent.horizontalCenter
y:170
color:"grey"
radius: 5
Grid {
id: gameGrid
columns: 4
rows: 4
anchors.centerIn: parent
spacing: 8
padding:8
Repeater {
model: gameManager.gridValues
Rectangle {
width: 78
height: 78
color: modelData == 2 ? "#EEE4DA" :
modelData == 4 ? "#EDE0C8" :
modelData == 8 ? "#F2B179" :
modelData == 16 ? "#F59563" :
modelData == 32 ? "#F67C5F" :
modelData == 64 ? "#F65E3B" :
modelData == 128 ? "#EDCF72" :
modelData == 256 ? "#EDCC61" :
modelData == 512 ? "#EDC850" :
modelData == 1024 ? "#EDC53F" :
modelData == 2048 ? "#EDC22E" : "#BBADA0"
radius: 5
Text {
text: modelData > 0 ? modelData : ""
anchors.centerIn: parent
font.bold: true
font.pixelSize: 30
color: "grey"
}
}
}
}
}
Rectangle {
id: menu
color:"#F65E3B"
width: 180; height: 30
anchors.horizontalCenter: parent.horizontalCenter
y:540
radius:5
Text{
anchors.centerIn: parent
text: "MENU "
color:"white"
font.bold: true
}
MouseArea{
anchors.fill: parent
onClicked: stackView.push("MenuPage.qml")
}
}
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();
}
}
}
import QtQuick
import QtQuick 2.15
import QtQuick.Controls 2.15
Window {
ApplicationWindow {
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
StackView {
id: stackView
anchors.fill: parent
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
initialItem: "GamePage.qml" // Charge la page du jeu
}
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: 5
Grid {
id: gameGrid
columns: 4
rows: 4
anchors.centerIn: parent
spacing: 8
padding:8
Repeater {
model: gameManager.gridValues
Rectangle {
width: 78
height: 78
color: modelData == 2 ? "#EEE4DA" :
modelData == 4 ? "#EDE0C8" :
modelData == 8 ? "#F2B179" :
modelData == 16 ? "#F59563" :
modelData == 32 ? "#F67C5F" :
modelData == 64 ? "#F65E3B" :
modelData == 128 ? "#EDCF72" :
modelData == 256 ? "#EDCC61" :
modelData == 512 ? "#EDC850" :
modelData == 1024 ? "#EDC53F" :
modelData == 2048 ? "#EDC22E" : "#BBADA0"
radius: 5
Text {
text: modelData > 0 ? modelData : ""
anchors.centerIn: parent
font.bold: true
font.pixelSize: 30
color: "grey"
}
}
}
}
}
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();
}
}
}
import QtQuick
import QtQuick.Controls
Rectangle {
width: 400
height: 600
color: "#FAF8EF"
Text{
text: "Menu"
font.bold: true
color:"grey"
font.pixelSize: 40
anchors.horizontalCenter: parent.horizontalCenter
y:70
}
MenuBar{
y:220
anchors.horizontalCenter: parent.horizontalCenter
background: Rectangle { color: "#BBADA0"; radius: 5 }
Menu{
title:"police"
MenuItem {
text: "Arial"
background: Rectangle { color: "black"; radius: 5 } // Fond et coins arrondis
}
}
}
MenuBar{
y:300
anchors.horizontalCenter: parent.horizontalCenter
background: Rectangle { color: "#BBADA0"; radius: 5 }
Menu{
title:"couleurs du jeu"
}
}
Rectangle {
color:"red"
width: 90; height: 30
anchors.horizontalCenter: parent.horizontalCenter
y:150
radius:5
MenuBar{
Menu{
title:"mode de jeu"
MenuItem {
text: "Grille 4x4"
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.modeDeJeu(1)
}
MenuItem {
text: "Grille 8x8"
background: Rectangle { color: "grey"; radius: 5 }
onTriggered: gameManager.modeDeJeu(2)
}
}
}
}
Rectangle {
color:"blue"
width: 90; height: 30
anchors.horizontalCenter: parent.horizontalCenter
y:510
radius:5
Text{
anchors.centerIn: parent
text: "Retour "
color:"white"
font.bold: true
}
MouseArea{
anchors.fill: parent
onClicked: stackView.pop()
}
}
}
import QtQuick
Item {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment