From c5dfde850f4c8b7a4924baff203e4462f9540b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathis=20Rib=C3=A9mont?= Date: Mon, 29 Nov 2021 10:44:11 +0100 Subject: [PATCH 1/2] prototype file on git --- Projet tut proto | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Projet tut proto diff --git a/Projet tut proto b/Projet tut proto new file mode 100644 index 0000000..5fd7652 --- /dev/null +++ b/Projet tut proto @@ -0,0 +1,50 @@ +enum etat: PLACEMENT, JEU, CONFIGURATION + +Plateau: + Pions: collection Pion + Pont: + verti: bool[4][5] + horiz: bool[5][4] + +Partie: + tabJoueurs: joueur + nbJoueurs: int + plateau: Plateau + joueurActuel: joueurs //index + nbTours: int + durée: int + etat: Etat //enumeration + +Ile: + x:int + y:int + +Pion: + indexJoueurs: int //index du joueurs dans le tableau + coordonnées: ile + isBloque: bool + +Joueur: + numJoueur (1,2,3,4) {unique par partie} + couleur: enum couleur + classement: int + +Moteur: + bouton extends rectangle: + + +fenêtre option: new SDL_Windows modal +sélection au click +ile = coordonnées +personnage: elfe, chapeau change de couleur + +getIlesAccessible:Pion, plateau -> tab iles //retourne les iles accessibles depuis un +deplacerPion: pion*, ilesDestination -> boolErreur (juste pour la prog) +retirerPont: pont -> bool (possible ou non, selon si déjà retirer) + au click: soit conversion de coordonnées pour vérifié si pont cliqué + soit rectangle invisible qui sert de hit box +getPionByIsle: plateau,Ile -> pions //regarde si un pions est présent à des coordonnées +hitbox sur ile adjacente et pas toutes les iles + +au bout de 30s si pas de connection: + annulation partie From 471dab296b2cb726e4140d5a136f8c2de35d9aa3 Mon Sep 17 00:00:00 2001 From: thmaillarb Date: Mon, 29 Nov 2021 11:20:34 +0100 Subject: [PATCH 2/2] Added struct Board and function newPiece() --- Pontu/include/model/Board.h | 32 ++++++++++++++++++++++++++++++++ Pontu/include/model/Piece.h | 8 +++++++- Pontu/src/model/Board.c | 26 ++++++++++++++++++++++++++ Pontu/src/model/Piece.c | 9 +++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 Pontu/include/model/Board.h create mode 100644 Pontu/src/model/Board.c diff --git a/Pontu/include/model/Board.h b/Pontu/include/model/Board.h new file mode 100644 index 0000000..c1af9fe --- /dev/null +++ b/Pontu/include/model/Board.h @@ -0,0 +1,32 @@ +/** + * \file Board.h + * \brief Board management + * \author Théotime Maillarbaux + * \date 29/11/221 + */ + +#ifndef BOARD_H +#define BOARD_H + +#include +#include "model/Piece.h" +#include // SDL_Color + +/** + * \struct Board + * \brief Represents a board for a Game. + * + * The bridges are represented by 2D-arrays of SDL_Bools. + * For a given set of coordinates, the value is TRUE if the bridge is there, + * else false. + */ +typedef struct { + // y x + bool vBridges[4][5]; ///< 2D-array of vertical bridges. + bool hBridges[5][4]; ///< 2D-array of horizontal bridges. + Piece arrPieces[9]; ///< Array of pieces on the Board. +} Board; + +Board newBoard(int nbPlayers); + +#endif // BOARD_H diff --git a/Pontu/include/model/Piece.h b/Pontu/include/model/Piece.h index aca450d..6ceb54a 100644 --- a/Pontu/include/model/Piece.h +++ b/Pontu/include/model/Piece.h @@ -9,6 +9,7 @@ #define PIECE_H #include "Island.h" //#include "Player.h" //If we use a pointer for the player instead of an int +#include /** *\Struct Piece @@ -20,7 +21,12 @@ typedef struct int idJ; ///< Player's id (owner of the piece) bool stuck; ///< Evaluate to true if the piece is isolated Island island; ///< Piece's localisation on the game board - }Piece; +/** + * \brief Creates a new Piece + * \param[in] idJ The ID (index in array) of the Player owning the Piece + */ +Piece newPiece(int idJ); + #endif // PIECE_H diff --git a/Pontu/src/model/Board.c b/Pontu/src/model/Board.c new file mode 100644 index 0000000..4b753f9 --- /dev/null +++ b/Pontu/src/model/Board.c @@ -0,0 +1,26 @@ +#include "model/Board.h" + +Board newBoard(int nbPlayers) { + Board board; + int nbPiecesPerPlayer = (nbPlayer == 4) ? 2 : 3; + int pieceIndex = 0; + + // Init pieces + for (int player_i = 0; i < nbPlayers; player_i++) { + for (int piece_i = 0; i < nbPiecesPerPlayer; piece_i++) { + board.arrPieces[pieceIndex] = newPiece(player_i); + pieceIndex++; + } + } + + // Init bridges + // max of vy (vertical y) is equal to max of hx (horizontal x), + // so vy will be used as hx as well. + for (int vy = 0; vy < 4; vy++) { + for (int vx = 0; vx < 5; vx++) { + board.vBridges[vy][vx] = true; + board.hBridges[vx][vy] = false; + } + } + return board; +} diff --git a/Pontu/src/model/Piece.c b/Pontu/src/model/Piece.c index e69de29..9a8657e 100644 --- a/Pontu/src/model/Piece.c +++ b/Pontu/src/model/Piece.c @@ -0,0 +1,9 @@ +#include "model/Piece.h" + +Piece newPiece(int idJ) { + Piece piece; + piece.idJ = idJ; + piece.stuck = false; + return piece; +} +