Martin ROUAULT 4 years ago
commit d6db39d042

@ -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 <stdbool.h>
#include "model/Piece.h"
#include <SDL2/SDL_pixels.h> // 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

@ -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 <stdbool.h>
/**
*\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

@ -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;
}

@ -0,0 +1,9 @@
#include "model/Piece.h"
Piece newPiece(int idJ) {
Piece piece;
piece.idJ = idJ;
piece.stuck = false;
return piece;
}

@ -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
Loading…
Cancel
Save