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

arrivée de sara

parent ee013f72
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,9 @@ qt_add_qml_module(appapplicationQT2048 ...@@ -17,6 +17,9 @@ qt_add_qml_module(appapplicationQT2048
VERSION 1.0 VERSION 1.0
QML_FILES QML_FILES
Main.qml Main.qml
QML_FILES MonElement.qml
SOURCES gamemanager.h gamemanager.cpp
SOURCES gamemanager.h gamemanager.cpp
) )
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
......
import QtQuick import QtQuick
Window { Window {
width: 640
height: 480
visible: true visible: true
title: qsTr("Hello World") width: 400
height: 500
title: qsTr("Application 2048")
Rectangle{
width:150;height:150
color:"orange"
x:25
y:10
}
Rectangle{
color:"black"
width: 90; height: 50
x:270
y:10
radius:10
Text{
text: "meilleur score"
color:"white"
anchors.horizontalCenter: parent.horizontalCenter
y:5
}
Text{
id: bestScore
text:"0"
color:"white"
font.bold: true
font.pixelSize: 20
anchors.horizontalCenter: parent.horizontalCenter
y:20
}
}
Rectangle {
id: buttonNew
color:"#F65E3B"
width: 90; height: 40
x:160
y:65
radius:10
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: 40
x:270
y:65
radius:10
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:120
color:"brown"
radius: 10
Grid {
id: gameGrid
columns: 4
rows: 4
anchors.centerIn: parent
spacing: 5
Repeater {
model: 16
Rectangle {
width: 80
height: 80
color: "lightgrey"
border.color: "black"
radius:10
Text {
anchors.centerIn: parent
text: ""
} }
}
}
}
}
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
Item {
}
#include "gamemanager.h"
GameManager::GameManager(QObject *parent) : QObject(parent), grid(4, std::vector<int>(4, 0)) {
generateTile();
generateTile();
}
void GameManager::moveLeft() {
// Implémentation du mouvement vers la gauche
}
void GameManager::moveRight() {
// Implémentation du mouvement vers la droite
}
void GameManager::moveUp() {
// Implémentation du mouvement vers le haut
}
void GameManager::moveDown() {
// Implémentation du mouvement vers le bas
}
void GameManager::restartGame() {
grid.assign(4, std::vector<int>(4, 0));
generateTile();
generateTile();
}
void GameManager::generateTile() {
// Implémentation de la génération de tuiles
}
void GameManager::mergeTiles() {
// Implémentation de la fusion des tuiles
}
#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H
#include <QObject>
#include <vector>
class GameManager : public QObject
{
Q_OBJECT
public:
explicit GameManager(QObject *parent = nullptr);
Q_INVOKABLE void moveLeft();
Q_INVOKABLE void moveRight();
Q_INVOKABLE void moveUp();
Q_INVOKABLE void moveDown();
Q_INVOKABLE void restartGame();
private:
std::vector<std::vector<int>> grid;
void generateTile();
void mergeTiles();
};
#endif // GAMEMANAGER_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment