Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
338df7af3d
23
README
23
README
@ -16,3 +16,26 @@ Reminder : les missiles sont tirés par les envahisseurs, et les torpilles par l
|
||||
|
||||
Quelques unes des problèmes rencontrés :
|
||||
- La sépararation entre l'affichage et la logique nous force à calculer les positions 2 fois (pour le bounc checking, et le l'affichage)'
|
||||
|
||||
```
|
||||
DOC
|
||||
|
||||
game.h :
|
||||
scoremanager
|
||||
displayAll : const missing non? j'ai mit "in" faudra voir
|
||||
manageOnePlayer : const missing non? j'ai mit "in" faudra voir
|
||||
le fin du fichier game.h enfaite lol
|
||||
|
||||
god.h
|
||||
tout lol
|
||||
|
||||
invadergrid.h
|
||||
les randomValid j'ai du mal a saisir
|
||||
|
||||
player.h
|
||||
x ?
|
||||
DeathAnimCounter issou j'ai la flemme d'aller chercher ou c'est used
|
||||
|
||||
configData.h
|
||||
map<InvaderType, InvaderTypeDef> invadersDef; comment est ce que j'explique une map xD?
|
||||
```
|
10
config.yml
10
config.yml
@ -1,6 +1,6 @@
|
||||
# General configuration
|
||||
general:
|
||||
maxFPS: 50
|
||||
maxFPS: 30
|
||||
|
||||
# Players config
|
||||
players:
|
||||
@ -25,7 +25,7 @@ players:
|
||||
# Enemies config
|
||||
invaders:
|
||||
fireCooldown: 20
|
||||
size: 25
|
||||
size: 40
|
||||
speed: 7
|
||||
distance: 10 # distance in pixels between invaders
|
||||
|
||||
@ -54,6 +54,6 @@ projectiles:
|
||||
# Grid definition
|
||||
# You can add more rows, make rows longer and add spaces
|
||||
grid:
|
||||
- "AAAAAAAAAAAA"
|
||||
- "BBBBBBBBBBBB"
|
||||
- "CCCCCCCCCCCC"
|
||||
- " "
|
||||
- " "
|
||||
- "B"
|
||||
|
@ -1,3 +1,13 @@
|
||||
/*!
|
||||
*
|
||||
* @file configData.h
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief Configuration file data storage
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GUARD_CONFIGDATA_H
|
||||
#define GUARD_CONFIGDATA_H
|
||||
|
||||
@ -9,37 +19,116 @@
|
||||
|
||||
typedef string configKey;
|
||||
|
||||
|
||||
/*!
|
||||
* @struct ConfigData
|
||||
* @brief this struct stores all relevant data from the configuration file
|
||||
*/
|
||||
struct ConfigData {
|
||||
|
||||
|
||||
/*!
|
||||
* @brief maximum framerate at which the game will run
|
||||
*/
|
||||
unsigned maxFPS;
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* @brief Invader type matrix
|
||||
*/
|
||||
InvadersGrid grid;
|
||||
|
||||
/*!
|
||||
* @brief players horizontal start position
|
||||
*/
|
||||
unsigned startXPosition;
|
||||
|
||||
/*!
|
||||
* @brief player movement speed
|
||||
*/
|
||||
unsigned playersSpeed;
|
||||
|
||||
/*!
|
||||
* @brief player horizontal size in pixel
|
||||
*/
|
||||
unsigned playersWidth;
|
||||
|
||||
/*!
|
||||
* @brief player shooting wait time
|
||||
*/
|
||||
unsigned playersFireCooldown;
|
||||
|
||||
/*!
|
||||
* @brief player life points
|
||||
*/
|
||||
unsigned playersLives;
|
||||
|
||||
/*!
|
||||
* @brief player key configuration
|
||||
*/
|
||||
vector<PlayerDef> playerDefs;
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* @brief invader movement speed
|
||||
*/
|
||||
unsigned invadersSpeed;
|
||||
|
||||
/*!
|
||||
* @brief invader radius size in pixel
|
||||
*/
|
||||
unsigned invadersSize;
|
||||
|
||||
/*!
|
||||
* @brief distance in pixel between two invader
|
||||
*/
|
||||
unsigned invadersDistance;
|
||||
|
||||
/*!
|
||||
* @brief wait time between two invader missile
|
||||
*/
|
||||
unsigned invadersFireCooldown;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
map<InvaderType, InvaderTypeDef> invadersDef;
|
||||
|
||||
/*!
|
||||
* @brief invaders missiles width in pixel
|
||||
*/
|
||||
unsigned missilesWidth;
|
||||
unsigned missilesLength; // auto defined from width
|
||||
|
||||
/*!
|
||||
* @brief invaders missiles length in pixel - auto defined from width
|
||||
*/
|
||||
unsigned missilesLength;
|
||||
|
||||
/*!
|
||||
* @brief invaders missiles movement speed
|
||||
*/
|
||||
unsigned missilesSpeed;
|
||||
|
||||
/*!
|
||||
* @brief invaders missiles color
|
||||
*/
|
||||
nsGraphics::RGBAcolor missilesColor;
|
||||
|
||||
/*!
|
||||
* @brief players torpedos width in pixel
|
||||
*/
|
||||
unsigned torpedosWidth;
|
||||
unsigned torpedosLength; // auto defined from width
|
||||
|
||||
/*!
|
||||
* @brief players torpedos length in pixel // auto defined from width
|
||||
*/
|
||||
unsigned torpedosLength;
|
||||
|
||||
/*!
|
||||
* @brief players topedos movement speed
|
||||
*/
|
||||
unsigned torpedosSpeed;
|
||||
|
||||
/*!
|
||||
* @brief players torpedos color
|
||||
*/
|
||||
nsGraphics::RGBAcolor torpedosColor;
|
||||
};
|
||||
|
||||
|
199
headers/game.h
199
headers/game.h
@ -1,3 +1,15 @@
|
||||
/**
|
||||
*
|
||||
* @file game.h
|
||||
* @author RUBINI Thomas
|
||||
* @author SIMAILA Djalim
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief full game logic and display management
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
#ifndef GUARD_GAME_H
|
||||
#define GUARD_GAME_H
|
||||
#include <vector>
|
||||
@ -15,63 +27,240 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*!
|
||||
* @class Game
|
||||
* @brief Main game class
|
||||
*/
|
||||
class Game {
|
||||
private:
|
||||
|
||||
/*!
|
||||
* @brief the MinGL window in which the game will be drawn into
|
||||
*/
|
||||
MinGL window;
|
||||
|
||||
/*!
|
||||
* @brief PixelManager : Class that contains and draws all the data that will be drawn on screen
|
||||
*/
|
||||
PixelManager pm;
|
||||
|
||||
/*!
|
||||
* @brief ConfigData : Struct that stores all the relevant data read from the configuration file
|
||||
*/
|
||||
ConfigData confData;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
ScoresManager sm;
|
||||
|
||||
/*!
|
||||
* @brief Special entity : God
|
||||
*/
|
||||
God god;
|
||||
|
||||
|
||||
/*!
|
||||
* @brief base position for game display
|
||||
*/
|
||||
Position basePos;
|
||||
|
||||
/*!
|
||||
* @brief Invader posision and type matrix
|
||||
*/
|
||||
InvadersGrid grid;
|
||||
|
||||
/*!
|
||||
* @brief Invader scroll direction - True = right , False = left
|
||||
*/
|
||||
bool direction = true;
|
||||
|
||||
|
||||
/*!
|
||||
* @brief list of postion of all missiles shot by the invaders
|
||||
*/
|
||||
vector<missile> missiles;
|
||||
|
||||
/*!
|
||||
* @brief list of postion of all torpedos shot by the player(s)
|
||||
*/
|
||||
vector<Torpedo> torpedos;
|
||||
|
||||
|
||||
/*!
|
||||
* @brief Define the current type of the game
|
||||
*/
|
||||
PlayMode playMode;
|
||||
|
||||
/*!
|
||||
* @brief list of all player data
|
||||
*/
|
||||
vector<Player> players;
|
||||
|
||||
// invaders related variables
|
||||
|
||||
/*!
|
||||
* @brief cooldown between two invader shot in milliseconds
|
||||
*/
|
||||
unsigned fireCooldown=120;
|
||||
|
||||
// basic methods
|
||||
|
||||
/*!
|
||||
* @brief Set or reset all the setting for a new game
|
||||
* @fn void initGame();
|
||||
*/
|
||||
void initGame();
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return true if there are no more invaders in the grid
|
||||
* @fn bool updateColumns();
|
||||
*/
|
||||
bool updateColumns();
|
||||
|
||||
/*!
|
||||
* @brief Asks the player(s) name(s) and write their score to the score file
|
||||
* @fn void handleScoreSaving();
|
||||
*/
|
||||
void handleScoreSaving();
|
||||
|
||||
/*!
|
||||
* @brief convert invader's matrix position to pixel coodinates
|
||||
* @return pixel position object
|
||||
* @fn Position invIndexToPos(unsigned x, unsigned y) const;
|
||||
*/
|
||||
Position invIndexToPos(unsigned x, unsigned y) const;
|
||||
|
||||
// drawing methods
|
||||
|
||||
/*!
|
||||
* @brief main display function, clear the window and calls sub display functions
|
||||
* @param[in] fps : current screen framerate
|
||||
* @fn void displayAll(unsigned fps) const;
|
||||
*/
|
||||
void displayAll(unsigned fps) const;
|
||||
|
||||
/*!
|
||||
* @brief display God related objets
|
||||
* @fn void displayGod() const;
|
||||
*/
|
||||
void displayGod() const;
|
||||
|
||||
/*!
|
||||
* @brief display a singular invader
|
||||
* @param[in] basePos : invader's pixel coordinates
|
||||
* @param[in] type : invader's type
|
||||
* @fn void displayInvader(const Position& basePos, InvaderType type) const
|
||||
*/
|
||||
void displayInvader(const Position& basePos, InvaderType type) const;
|
||||
|
||||
/*!
|
||||
* @brief displays a player's remaining lives
|
||||
* @fn void displayHearts(playerID) const;
|
||||
*/
|
||||
void displayHearts(playerID) const;
|
||||
|
||||
|
||||
// managers
|
||||
|
||||
/*!
|
||||
* @brief Calls the function 'ManageOnePlayer' for all players in player list
|
||||
* @fn void managePlayers();
|
||||
*/
|
||||
void managePlayers();
|
||||
void manageOnePlayer(playerID);
|
||||
|
||||
/*!
|
||||
* @brief Handles a player keystrokes, makes them move or make them shoot a torpedo
|
||||
* @param[in] pID : Player id
|
||||
* @fn void manageOnePlayer(playerID pID);
|
||||
*/
|
||||
void manageOnePlayer(playerID pID);
|
||||
|
||||
/*!
|
||||
* @brief Handles all invaders movements and when they'll shoot a missile
|
||||
* @return true if the invaders went down from one line (and we should check lower boundary), else false
|
||||
* @fn bool manageInvaders();
|
||||
*/
|
||||
bool manageInvaders();
|
||||
|
||||
// collision things
|
||||
|
||||
/*!
|
||||
* @brief Removes torpedo and missiles that are colliding
|
||||
* @fn void remCollidingProjectiles();
|
||||
*/
|
||||
void remCollidingProjectiles();
|
||||
|
||||
/*!
|
||||
* @brief Makes all missiles go downward
|
||||
* @fn void moveMissiles();
|
||||
*/
|
||||
void moveMissiles();
|
||||
|
||||
/*!
|
||||
* @brief Makes all torpedos go upward
|
||||
* @fn void moveTorpedos();
|
||||
*/
|
||||
void moveTorpedos();
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
bool checkMissilesAndPlayers();
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
bool checkTorpedosAndInvaders();
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
bool invadersTouchPlayer() const;
|
||||
|
||||
// god things
|
||||
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
void awakeGod();
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
bool manageGod();
|
||||
|
||||
public:
|
||||
// in case someone wants to mess with the code, here's a minimal API, costs nothing to us
|
||||
Game();
|
||||
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
Game();
|
||||
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
void managedGames();
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
WinValue enterGameLoop();
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
bool reloadConfig();
|
||||
};
|
||||
|
||||
|
@ -1,9 +1,22 @@
|
||||
/*!
|
||||
*
|
||||
* @file god.h
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief Special entity known as "God"
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GUARD_GOD_H
|
||||
#define GUARD_GOD_H
|
||||
|
||||
#include "utils.h"
|
||||
#include "invadersGrid.h"
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
enum class GodState{
|
||||
NONE,
|
||||
AWAKE,
|
||||
@ -13,30 +26,69 @@ enum class GodState{
|
||||
THROW,
|
||||
YOLO,
|
||||
};
|
||||
|
||||
|
||||
// I don't want to put that in config, I feel like it would be useless and overkill at this point
|
||||
#define GOD_BENCH_SIZE 64
|
||||
#define GOD_HAND_SIZE 64
|
||||
#define GOD_HAND_DISTANCE 100
|
||||
|
||||
|
||||
/*
|
||||
/*!
|
||||
* Hand position is determined
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* @class God
|
||||
* @brief
|
||||
*/
|
||||
class God{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
GodState state;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
unsigned counter;
|
||||
|
||||
|
||||
// we do not use a Position because it is used for pixel X and Y
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
unsigned thrownInvPosX;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
unsigned thrownInvPosY;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
InvaderType thrownInvType;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
Position thrownVector;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
Position thrownTransition;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[in] screenWidth :
|
||||
* @return
|
||||
* @fn Position getRightHandPos(unsigned screenWidth) const;
|
||||
*/
|
||||
Position getRightHandPos(unsigned screenWidth) const;
|
||||
|
||||
};
|
||||
|
@ -1,11 +1,32 @@
|
||||
/*!
|
||||
*
|
||||
* @file invaderDef.h
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief invader type deffinition and related data
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GUARD_INVADERDEF_H
|
||||
#define GUARD_INVADERDEF_H
|
||||
|
||||
#include "mingl/graphics/rgbacolor.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
/*!
|
||||
* @struct InvaderTypeDef
|
||||
* @brief defines an invader type
|
||||
*/
|
||||
struct InvaderTypeDef {
|
||||
/*!
|
||||
* @brief color of the invader type
|
||||
*/
|
||||
nsGraphics::RGBAcolor color;
|
||||
|
||||
/*!
|
||||
* @brief points given to the player by defeating this invader type
|
||||
*/
|
||||
unsigned points;
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,14 @@
|
||||
/*!
|
||||
*
|
||||
* @file invaderGrid.h
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief invader matrix structure
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GUARD_INVADERSGRID_H
|
||||
#define GUARD_INVADERSGRID_H
|
||||
|
||||
@ -5,22 +16,60 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*!
|
||||
* @brief List of all invader type
|
||||
*/
|
||||
enum class InvaderType {
|
||||
TYPEA,
|
||||
TYPEB,
|
||||
TYPEC,
|
||||
NONE,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @class InvadersColumn
|
||||
* @brief Column of invader
|
||||
*/
|
||||
class InvadersColumn : public vector<InvaderType>{
|
||||
public:
|
||||
// idk why CLion says this is not implemented, but it is
|
||||
|
||||
/*!
|
||||
* @brief tells if the column contains no non type NONE invader
|
||||
* @return True if there's only type NONE invader, False elsewise
|
||||
* @fn bool hasNoValid() const;
|
||||
*/
|
||||
bool hasNoValid() const;
|
||||
|
||||
/*!
|
||||
* @brief gives the index of the last valid (type different than NONE) invader
|
||||
* @return index of the last valid invader if found, else size of the column
|
||||
* @fn unsigned getOutterInvader() const;
|
||||
*/
|
||||
unsigned getOutterInvader() const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
unsigned randomValid() const;
|
||||
};
|
||||
}; // class InvadersColumn
|
||||
|
||||
|
||||
/*!
|
||||
* @class InvadersColumn
|
||||
* @brief Column of invader
|
||||
*/
|
||||
class InvadersGrid : public vector<InvadersColumn>{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @brief List of all invader type
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
unsigned randomValid() const;
|
||||
};
|
||||
}; // InvadersGrid
|
||||
|
||||
#endif
|
@ -1,12 +1,41 @@
|
||||
/*!
|
||||
*
|
||||
* @file menu.h
|
||||
* @author SIMAILA Djalim
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief simple menu backend implementation
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GUARD_MENU_H
|
||||
#define GUARD_MENU_H
|
||||
#include"vector"
|
||||
#include"string"
|
||||
|
||||
/*!
|
||||
* @struct Menu
|
||||
* @brief menu stuct
|
||||
*/
|
||||
struct Menu{
|
||||
/*!
|
||||
* @brief list of all menu options
|
||||
*/
|
||||
vector<string> entries;
|
||||
|
||||
/*!
|
||||
* @brief index of currently selected menu option
|
||||
*/
|
||||
size_t currentValue = 0;
|
||||
|
||||
/*!
|
||||
* @brief color of currently selected menu option
|
||||
*/
|
||||
nsGraphics::RGBAcolor selectedColor;
|
||||
/*!
|
||||
* @brief color of unelected menu option
|
||||
*/
|
||||
nsGraphics::RGBAcolor unSelectedColor;
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,15 @@
|
||||
/*!
|
||||
*
|
||||
* @file pixelManager.h
|
||||
* @author RUBINI Thomas
|
||||
* @author SIMAILA Djalim
|
||||
* @author FABRE Lucas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief manager
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GUARD_PIXELMANAGER_H
|
||||
#define GUARD_PIXELMANAGER_H
|
||||
|
||||
@ -17,6 +29,11 @@ using namespace std;
|
||||
|
||||
#define MIRROR(SP) mirrorData((SP).getPixelData(), (SP).getRowSize()), (SP).getRowSize()
|
||||
|
||||
|
||||
/*!
|
||||
* @class PixelManager
|
||||
* @brief main display function, clear the window and calls sub display functions
|
||||
*/
|
||||
class PixelManager{
|
||||
public:
|
||||
MinGL& window;
|
||||
@ -29,47 +46,195 @@ public:
|
||||
*
|
||||
* (We could copy them every time, but I feel like copying image data every frame isn't great)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
nsGui::Sprite logo{"assets/logo.si2"};
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
nsGui::Sprite gameBackground{"assets/game_background.si2"};
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
nsGui::Sprite menuBackground{"assets/menu_background.si2"};
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
nsGui::Sprite rightHand{"assets/hand_open.si2"};
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
nsGui::Sprite leftHand{MIRROR(rightHand)};
|
||||
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
explicit PixelManager(MinGL&);
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[in] baseVector :
|
||||
* @param[in] size :
|
||||
* @param[in] color :
|
||||
* @fn
|
||||
*/
|
||||
void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[in] baseVector :
|
||||
* @param[in] size :
|
||||
* @param[in] color :
|
||||
* @fn
|
||||
*/
|
||||
void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[in] baseVector
|
||||
* @param[in] size
|
||||
* @param[in] color
|
||||
* @fn
|
||||
*/
|
||||
void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||
|
||||
#define HEART_LENGTH 40
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawHeart(const Position& baseVector) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawSprite(const nsGui::Sprite& sprite, const Position& pos) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color);
|
||||
// TODO remove because unused ?
|
||||
void displayText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void displayMenu(const Position& pos, Menu& currentMenu);
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawGameBackground() const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawMenuBackground() const;
|
||||
|
||||
// TODO remove because unused ?
|
||||
void displayText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawFPS(unsigned fps) const;
|
||||
|
||||
PlayMode showInitialMenu();
|
||||
bool showDeathMenu() const;
|
||||
PlayMode showDeathMenu();
|
||||
unsigned getScreenHeight() const;
|
||||
unsigned getScreenWidth() const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void startFrame() const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void endFrame() const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void askPlayerNameMenu(playerID pID, string& name) const;
|
||||
|
||||
// y will be negative sometimes, so not unsigned
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawGodBench(int y) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawGodRightHand(const Position& pos) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawGodLeftHand(const Position& pos) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
*/
|
||||
void drawGodFace(int y, bool angry=false) const;
|
||||
|
||||
private:
|
||||
|
@ -1,6 +1,19 @@
|
||||
/*!
|
||||
*
|
||||
* @file playMode.h
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief game mode options
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GUARD_PLAYMODE_H
|
||||
#define GUARD_PLAYMODE_H
|
||||
|
||||
/*!
|
||||
* @brief List of all game playmode
|
||||
*/
|
||||
enum class PlayMode {
|
||||
NONE,
|
||||
SINGLE,
|
||||
|
@ -1,13 +1,51 @@
|
||||
/**
|
||||
*
|
||||
* @file player.h
|
||||
* @author RUBINI Thomas
|
||||
* @author SIMAILA Djalim
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief player data storage
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef GUARD_PLAYER_H
|
||||
#define GUARD_PLAYER_H
|
||||
|
||||
/*!
|
||||
* @struct Player
|
||||
* @brief player data structure
|
||||
*/
|
||||
struct Player{
|
||||
|
||||
/*!
|
||||
* @brief player life points
|
||||
*/
|
||||
unsigned lives = 3;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
unsigned x;
|
||||
|
||||
/*!
|
||||
* @brief player's unique identidier
|
||||
*/
|
||||
unsigned id;
|
||||
|
||||
/*!
|
||||
* @brief player's personal score
|
||||
*/
|
||||
unsigned score=0;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
*/
|
||||
unsigned deathAnimCounter=0;
|
||||
|
||||
/*!
|
||||
* @brief player's shooting cooldown
|
||||
*/
|
||||
unsigned fireCooldown=0;
|
||||
|
||||
// TODO remove ?
|
||||
|
@ -1,16 +1,54 @@
|
||||
/*!
|
||||
*
|
||||
* @file playerDef.h
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief player key configuration
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GUARD_PLAYER_DEF_H
|
||||
#define GUARD_PLAYER_DEF_H
|
||||
|
||||
#include "mingl/graphics/rgbacolor.h"
|
||||
|
||||
/*!
|
||||
* @struct PlayerKeys
|
||||
* @brief player key configuration
|
||||
*/
|
||||
struct PlayerKeys {
|
||||
|
||||
/*!
|
||||
* @brief key to move right
|
||||
*/
|
||||
char right;
|
||||
|
||||
/*!
|
||||
* @brief key to move left
|
||||
*/
|
||||
char left;
|
||||
|
||||
/*!
|
||||
* @brief key to shoot
|
||||
*/
|
||||
char shoot;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @struct PlayerDef
|
||||
* @brief player data, contains colors and key configuration
|
||||
*/
|
||||
struct PlayerDef {
|
||||
|
||||
/*!
|
||||
* @brief player color
|
||||
*/
|
||||
nsGraphics::RGBAcolor color;
|
||||
|
||||
/*!
|
||||
* @brief player key configuration
|
||||
*/
|
||||
PlayerKeys keys;
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,13 @@
|
||||
/*!
|
||||
*
|
||||
* @file projectiles.h
|
||||
* @author SIMAILA Djalim
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief projectiles data storage
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GUARD_PROJECTILES_H
|
||||
#define GUARD_PROJECTILES_H
|
||||
|
||||
@ -5,9 +15,24 @@
|
||||
|
||||
typedef Position missile;
|
||||
|
||||
/*!
|
||||
* @class Torpedo
|
||||
* @brief player's projectiles
|
||||
*/
|
||||
class Torpedo : public Position {
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @brief id of the player that shot the torpedo
|
||||
*/
|
||||
playerID owner;
|
||||
|
||||
/*!
|
||||
* @brief constuctor for the torpedo class
|
||||
* @param[in] x : horizontal pixel coordinate
|
||||
* @param[in] y : vertical pixel coordinate
|
||||
* @fn Torpedo(int x, int y, playerID owner);
|
||||
*/
|
||||
Torpedo(int x, int y, playerID owner);
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,13 @@
|
||||
/*!
|
||||
*
|
||||
* @file ScoreManager.h
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief Score file manager
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GUARD_SCORESMANAGER_H
|
||||
#define GUARD_SCORESMANAGER_H
|
||||
|
||||
|
@ -1,6 +1,19 @@
|
||||
/*!
|
||||
*
|
||||
* @file configManagement.cpp
|
||||
* @author RUBINI Thomas
|
||||
* @author SIMAILA Djalim
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief config parser
|
||||
*
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include "game.h"
|
||||
|
||||
// you will MOVE THIS OUT OF THIS FILE
|
||||
|
||||
class ConfigBuilder{
|
||||
public:
|
||||
ConfigData collectedData;
|
||||
|
@ -1,3 +1,15 @@
|
||||
/*!
|
||||
*
|
||||
* @file drawEntity.cpp
|
||||
* @author RUBINI Thomas
|
||||
* @author SIMAILA Djalim
|
||||
* @author FABRE Lucas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief entity drawing functions
|
||||
*
|
||||
*/
|
||||
|
||||
#include <playMode.h>
|
||||
#include "pixelManager.h"
|
||||
#include "mingl/gui/text.h"
|
||||
|
@ -1,3 +1,14 @@
|
||||
/*!
|
||||
*
|
||||
* @file drawMenu.cpp
|
||||
* @author SIMAILA Djalim
|
||||
* @author FABRE Lucas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief menu drawing functions
|
||||
*
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <playMode.h>
|
||||
@ -10,9 +21,9 @@ using namespace nsShape;
|
||||
using namespace nsGraphics;
|
||||
|
||||
void PixelManager::displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color){
|
||||
window << Rectangle(Position(190, 430)+baseVector, Position(310, 465)+baseVector, KGray);
|
||||
window << Rectangle(Position(188, 428)+baseVector, Position(312, 467)+baseVector, KBlack);
|
||||
window << nsGui::Text(Vec2D(200, 450)+baseVector, text, color);
|
||||
window << Rectangle(baseVector, Position(180, 40)+baseVector, KGray);
|
||||
window << Rectangle(baseVector+Position(2,2), Position(178, 38)+baseVector, KBlack);
|
||||
window << nsGui::Text(baseVector+Position(10,22), text, color);
|
||||
}
|
||||
|
||||
void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
||||
@ -30,25 +41,25 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
||||
}
|
||||
|
||||
PlayMode PixelManager::showInitialMenu(){
|
||||
vector<string> entries {"single player","multi player (local)","EXIT"};
|
||||
vector<string> entries {"single player","multi player (local)","exit"};
|
||||
Menu initial {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
||||
const unsigned xOffset = getScreenHeight() / 2;
|
||||
const unsigned yOffset = getScreenWidth() / 2;
|
||||
const unsigned xOffset = getScreenHeight() / 2 ;
|
||||
const unsigned yOffset = getScreenWidth() / 2 - 90;
|
||||
chrono::milliseconds waitTime = chrono::milliseconds(100);
|
||||
while(true){
|
||||
displayMenu(Position(350,0),initial);
|
||||
displayMenu(Position(yOffset,xOffset),initial);
|
||||
// go down
|
||||
if (window.isPressed({'s', false})){
|
||||
++initial.currentValue;
|
||||
if (initial.currentValue > initial.entries.size()) initial.currentValue = 0;
|
||||
if (initial.currentValue > initial.entries.size()-1) initial.currentValue = 0;
|
||||
this_thread::sleep_for(waitTime);
|
||||
}
|
||||
}
|
||||
// go up
|
||||
if (window.isPressed({'z', false})){
|
||||
if (initial.currentValue == 0) initial.currentValue = initial.entries.size()-1;
|
||||
else --initial.currentValue;
|
||||
this_thread::sleep_for(waitTime);
|
||||
}
|
||||
}// select option
|
||||
else if (window.isPressed({13, false})){
|
||||
switch(initial.currentValue){
|
||||
case 0:
|
||||
@ -57,14 +68,45 @@ PlayMode PixelManager::showInitialMenu(){
|
||||
return PlayMode::TWO_LOCAL;
|
||||
case 2:
|
||||
return PlayMode::EXIT;
|
||||
default:
|
||||
return PlayMode::SINGLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool PixelManager::showDeathMenu() const {
|
||||
return true;
|
||||
PlayMode PixelManager::showDeathMenu() {
|
||||
vector<string> entries {"main menu","exit"};
|
||||
Menu death {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
||||
const unsigned xOffset = getScreenHeight() / 2 ;
|
||||
const unsigned yOffset = getScreenWidth() / 2 - 90;
|
||||
chrono::milliseconds waitTime = chrono::milliseconds(100);
|
||||
while(true){
|
||||
displayMenu(Position(yOffset,xOffset),death);
|
||||
// go down
|
||||
if (window.isPressed({'s', false})){
|
||||
++death.currentValue;
|
||||
if (death.currentValue > death.entries.size()-1) death.currentValue = 0;
|
||||
this_thread::sleep_for(waitTime);
|
||||
}
|
||||
// go up
|
||||
if (window.isPressed({'z', false})){
|
||||
if (death.currentValue == 0) death.currentValue = death.entries.size()-1;
|
||||
else --death.currentValue;
|
||||
this_thread::sleep_for(waitTime);
|
||||
}// select option
|
||||
else if (window.isPressed({13, false})){
|
||||
switch(death.currentValue){
|
||||
case 0:
|
||||
return PlayMode::NONE;
|
||||
case 1:
|
||||
return PlayMode::EXIT;
|
||||
default:
|
||||
return PlayMode::EXIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,14 @@
|
||||
/*!
|
||||
*
|
||||
* @file display.cpp
|
||||
* @author RUBINI Thomas
|
||||
* @author SIMAILA Djalim
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief game display
|
||||
*
|
||||
*/
|
||||
|
||||
#include "game.h"
|
||||
|
||||
|
||||
|
@ -1,10 +1,20 @@
|
||||
/*!
|
||||
*
|
||||
* @file gameBasics.cpp
|
||||
* @author RUBINI Thomas
|
||||
* @author SIMAILA Djalim
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief game basic mechanisms
|
||||
*
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include "game.h"
|
||||
#include "playMode.h"
|
||||
|
||||
#define WININIT window("space invader du turfu", Position(1280, 720), Position(128, 128), nsGraphics::KBlack)
|
||||
|
||||
#define WININIT window("SUPER Space Invader : Turbo Apocalypse DX - VS GOD", Position(1280, 720), Position(128, 128), nsGraphics::KBlack)
|
||||
|
||||
Game::Game() : WININIT, pm(window) {
|
||||
if(!reloadConfig()){
|
||||
@ -13,10 +23,6 @@ Game::Game() : WININIT, pm(window) {
|
||||
sm.readFile();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if there are no more invaders in the grid
|
||||
*/
|
||||
bool Game::updateColumns(){
|
||||
while(true){
|
||||
if(grid.empty())return true;
|
||||
@ -59,14 +65,11 @@ void Game::managedGames() {
|
||||
enterGameLoop(); // will read the playMode
|
||||
handleScoreSaving();
|
||||
cout << "END OF GAME" << endl;
|
||||
break; // TODO remove
|
||||
if(!pm.showDeathMenu()) playMode = PlayMode::NONE; // back to the main menu
|
||||
|
||||
playMode = pm.showDeathMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// we assume the game has been played before, and so we need to clean used members
|
||||
void Game::initGame(){
|
||||
grid = confData.grid; // will copy the grid
|
||||
|
@ -1,3 +1,13 @@
|
||||
/*!
|
||||
*
|
||||
* @file gameBasics.cpp
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief game basic mechanisms
|
||||
*
|
||||
*/
|
||||
|
||||
#include "game.h"
|
||||
|
||||
#define ISPRESSED(ID, X) window.isPressed({confData.playerDefs[ID].keys.X, false})
|
||||
|
@ -1,3 +1,13 @@
|
||||
/*!
|
||||
*
|
||||
* @file gameBasics.cpp
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief god's implementation
|
||||
*
|
||||
*/
|
||||
|
||||
#include "game.h"
|
||||
|
||||
void Game::awakeGod() {
|
||||
|
@ -1,9 +1,20 @@
|
||||
/*!
|
||||
*
|
||||
* @file invaderGrids.h
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief invader matrix structure
|
||||
*
|
||||
*/
|
||||
|
||||
#include<invadersGrid.h>
|
||||
#include<iostream>
|
||||
|
||||
bool InvadersColumn::hasNoValid() const {
|
||||
return getOutterInvader()==size();
|
||||
}
|
||||
|
||||
unsigned InvadersColumn::getOutterInvader() const {
|
||||
unsigned i=size();
|
||||
while(i>0){
|
||||
|
14
src/main.cpp
14
src/main.cpp
@ -1,3 +1,17 @@
|
||||
/*!
|
||||
*
|
||||
* @file main.cpp
|
||||
* @author RUBINI Thomas
|
||||
* @author SIMAILA Djalim
|
||||
* @author FABRE Lucas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief main
|
||||
*
|
||||
* Welcome to SUPER Space Invader turbo apocalypse DX - VS GOD
|
||||
* This little game was made in love by the glorious Thomas, the sublime Lucas, and the magnificent Djalim
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "game.h"
|
||||
using namespace std;
|
||||
|
@ -1,3 +1,14 @@
|
||||
/**
|
||||
*
|
||||
* @file player.h
|
||||
* @author RUBINI Thomas
|
||||
* @author SIMAILA Djalim
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief player data storage
|
||||
*
|
||||
**/
|
||||
|
||||
#include "player.h"
|
||||
|
||||
bool Player::isPlaying() const {
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*!
|
||||
*
|
||||
* @file projectiles.cpp
|
||||
* @author SIMAILA Djalim
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief projectiles data storage
|
||||
*
|
||||
*/
|
||||
#include "projectiles.h"
|
||||
|
||||
Torpedo::Torpedo(int x, int y, playerID owner) : Position(x, y) {
|
||||
|
@ -1,3 +1,13 @@
|
||||
/*!
|
||||
*
|
||||
* @file ScoreManager.cpp
|
||||
* @author RUBINI Thomas
|
||||
* @date January 2022
|
||||
* @version 1.0
|
||||
* @brief Score file manager
|
||||
*
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
Loading…
Reference in New Issue
Block a user