Skip to content
Snippets Groups Projects
Commit 0305df62 authored by Yanis Dziki's avatar Yanis Dziki
Browse files

Gen grille

parent 3f5856d2
Branches
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ qt_add_qml_module(appmotus
QML_FILES GameWindow.qml
SOURCES jeu.h jeu.cpp
SOURCES grillemanager.h grillemanager.cpp
QML_FILES Case.qml
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
......
import QtQuick
Rectangle {
width: 50
height: 50
radius: 5
color: etat === 0 ? "#ffffff" : etat === 1 ? "#fdd835" : "#66bb6a"
border.color: "#000000"
border.width: 1
property string letter: ""
property int etat: 0
Text {
anchors.centerIn: parent
text: letter
font.pixelSize: 24
font.bold: true
color: "#000"
}
}
......@@ -3,6 +3,9 @@
import QtQuick
Item {
width: 900
height: 800
......@@ -11,32 +14,26 @@ Item {
id: rectangle
color: "#ffffff"
anchors.fill: parent
Grid {
id: gridView
id: grille
anchors.top: parent.top
anchors.left: parent.left
anchors.topMargin: 50
anchors.horizontalCenter: parent.horizontalCenter
rows: 6
columns: 5
spacing: 5
Repeater {
model: grilleManager.cases
Rectangle {
width: 50
height: 50
color: modelData.etat === 0 ? "lightgray" :
modelData.etat === 1 ? "yellow" : "green"
border.color: "black"
Text {
anchors.centerIn: parent
text: modelData.letter
font.bold: true
}
model: jeu.grilleManager.cases
delegate: Case {
letter: modelData.letter
etat: modelData.etat
}
}
}
Clavier {
id: clavier
x: 225
......@@ -44,3 +41,4 @@ Item {
}
}
}
......@@ -39,7 +39,7 @@ Window {
y: 624
mouseArea.onClicked:{
pageLoader.source = "GameWindow.qml";
jeu.initGame();
jeu.startGame();
}
}
......
......@@ -7,5 +7,6 @@
<file>bouton.qml</file>
<file>Bouton.qml</file>
<file>GameWindow.qml</file>
<file>Case.qml</file>
</qresource>
</RCC>
......@@ -2,10 +2,7 @@
#include <iostream>
Jeu::Jeu(QObject *parent) : QObject(parent), brain("./") {
brain.setFichierDico("words_alpha.txt");
brain.setNombreEssais(5);
brain.setTailleMots(5);
brain.initGame();
mot = QString::fromStdString(brain.getMot()); // ✅ Conversion std::string → QString
......@@ -30,3 +27,15 @@ void Jeu::onClavierClick(QString lettre) {
void Jeu::initGame() {
brain.initGame();
}
void Jeu::startGame() {
brain.setFichierDico("words_alpha.txt");
brain.setNombreEssais(6); // ou ce que tu veux
brain.setTailleMots(5); // idem
brain.initGame();
grilleManager.createGrid(6, 5); // à synchroniser avec les paramètres du brain
}
......@@ -3,16 +3,21 @@
#include <QObject>
#include "brain.h"
#include "grillemanager.h"
class Jeu : public QObject {
Q_OBJECT
Q_PROPERTY(QString motAffiche READ getMotAffiche NOTIFY motChanged)
Q_PROPERTY(GrilleManager* grilleManager READ getGrilleManager CONSTANT)
public:
explicit Jeu(QObject *parent = nullptr);
QString getMotAffiche();
Q_INVOKABLE void onClavierClick(QString lettre);
Q_INVOKABLE void initGame();
Q_INVOKABLE void startGame(); // pour init depuis QML
GrilleManager* getGrilleManager() { return &grilleManager; }
signals:
void motChanged();
......@@ -20,6 +25,7 @@ signals:
private:
Brain brain;
QString mot;
GrilleManager grilleManager; // <- On le garde en vie ici
};
#endif // JEU_H
......@@ -13,9 +13,6 @@ int main(int argc, char *argv[]) {
qmlRegisterType<VraieCase>("motus", 1, 0, "VraieCase");
qmlRegisterType<GrilleManager>("motus", 1, 0, "GrilleManager");
GrilleManager grilleManager;
engine.rootContext()->setContextProperty("grilleManager", &grilleManager);
Jeu jeu;
engine.rootContext()->setContextProperty("jeu", &jeu);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment