things
This commit is contained in:
parent
f2822815dd
commit
7b2eda8549
@ -80,50 +80,56 @@ public:
|
|||||||
explicit PixelManager(MinGL&);
|
explicit PixelManager(MinGL&);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief
|
* @brief display a type A invader on screen
|
||||||
* @param[in] baseVector :
|
* @param[in] baseVector : pixel coordinate of the invader
|
||||||
* @param[in] size :
|
* @param[in] size : size multiplicator of the invader
|
||||||
* @param[in] color :
|
* @param[in] color : color multiplicaror of the invader
|
||||||
* @fn
|
* @fn void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||||
*/
|
*/
|
||||||
void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief
|
* @brief display a type B invader on screen
|
||||||
* @param[in] baseVector :
|
* @param[in] baseVector : pixel coordinate of the invader
|
||||||
* @param[in] size :
|
* @param[in] size : size multiplicator of the invader
|
||||||
* @param[in] color :
|
* @param[in] color : color multiplicaror of the invader
|
||||||
* @fn
|
* @fn void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||||
*/
|
*/
|
||||||
void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief
|
* @brief display a type C invader on screen
|
||||||
* @param[in] baseVector
|
* @param[in] baseVector : pixel coordinate of the invader
|
||||||
* @param[in] size
|
* @param[in] size : size multiplicator of the invader
|
||||||
* @param[in] color
|
* @param[in] color : color multiplicaror of the invader
|
||||||
* @fn
|
* @fn void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||||
*/
|
*/
|
||||||
void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief
|
* @brief display a player on screen
|
||||||
* @param[]
|
* @param[in] x : horizontal position of the player
|
||||||
* @fn
|
* @param[in] witdh : width of the player
|
||||||
|
* @param[in] color : color of the plater
|
||||||
|
* @fn void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
*/
|
*/
|
||||||
void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief
|
* @brief display a missile on screen
|
||||||
* @param[]
|
* @param[in] baseVector : pixel coordinates of the missile
|
||||||
* @fn
|
* @param[in] width : width of the missle
|
||||||
|
* @param[in] color : color of the missile
|
||||||
|
* @fn void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
*/
|
*/
|
||||||
void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief
|
* @brief display a torpedo on screen
|
||||||
* @param[]
|
* @param[in] baseVector : pixel coordinates of the torpedo
|
||||||
* @fn
|
* @param[in] width : width of the torpedo
|
||||||
|
* @param[in] color : color of the torpedo
|
||||||
|
* @fn void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
*/
|
*/
|
||||||
void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
|
|
||||||
@ -171,10 +177,32 @@ public:
|
|||||||
*/
|
*/
|
||||||
void drawFPS(unsigned fps) const;
|
void drawFPS(unsigned fps) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief
|
||||||
|
* @return
|
||||||
|
* @fn
|
||||||
|
*/
|
||||||
PlayMode showInitialMenu();
|
PlayMode showInitialMenu();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief
|
||||||
|
* @return
|
||||||
|
* @fn
|
||||||
|
*/
|
||||||
bool showDeathMenu();
|
bool showDeathMenu();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief
|
||||||
|
* @return
|
||||||
|
* @fn
|
||||||
|
*/
|
||||||
unsigned getScreenHeight() const;
|
unsigned getScreenHeight() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief
|
||||||
|
* @return
|
||||||
|
* @fn
|
||||||
|
*/
|
||||||
unsigned getScreenWidth() const;
|
unsigned getScreenWidth() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -21,13 +21,13 @@ using namespace std;
|
|||||||
struct ScoreLink{
|
struct ScoreLink{
|
||||||
string name;
|
string name;
|
||||||
unsigned score;
|
unsigned score;
|
||||||
ScoreLink(string&& name, unsigned score);
|
ScoreLink(string name, unsigned score);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScoresManager {
|
class ScoresManager {
|
||||||
public:
|
public:
|
||||||
vector<ScoreLink> scores;
|
vector<ScoreLink> scores;
|
||||||
void inputScore(string&& name, unsigned score);
|
void inputScore(string name, unsigned score);
|
||||||
void readFile();
|
void readFile();
|
||||||
void writeFile() const;
|
void writeFile() const;
|
||||||
};
|
};
|
||||||
|
@ -14,6 +14,16 @@
|
|||||||
* (We need to explicitly specify the default constructor)*/
|
* (We need to explicitly specify the default constructor)*/
|
||||||
#define INV_GET_POS(i) confData.invadersSize*(i)+confData.invadersDistance*(i)
|
#define INV_GET_POS(i) confData.invadersSize*(i)+confData.invadersDistance*(i)
|
||||||
|
|
||||||
|
// Syntax : DEBUG(cout << "hey" << endl)
|
||||||
|
// The debug flag defintion has been set here, but normally we would add it to the MakeFile
|
||||||
|
#define DEBUG_FLAG
|
||||||
|
|
||||||
|
#ifdef DEBUG_FLAG
|
||||||
|
#define DEBUG(X) X;
|
||||||
|
#else
|
||||||
|
#define DEBUG(X)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using nsGraphics::RGBAcolor;
|
using nsGraphics::RGBAcolor;
|
||||||
|
@ -18,10 +18,12 @@ using namespace std;
|
|||||||
|
|
||||||
// TODO changer tout les unsigned par des size_t dans les boucles
|
// TODO changer tout les unsigned par des size_t dans les boucles
|
||||||
int main(){
|
int main(){
|
||||||
|
DEBUG(cout << "Starting program" << endl)
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
Game g;
|
Game g;
|
||||||
g.managedGames();
|
g.managedGames();
|
||||||
|
DEBUG(cout << "Finished program. Goodbye !" << endl)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -86,21 +86,23 @@ void ScoresManager::writeFile() const {
|
|||||||
/**
|
/**
|
||||||
* Insertion sort, probably the most efficient here
|
* Insertion sort, probably the most efficient here
|
||||||
*/
|
*/
|
||||||
void ScoresManager::inputScore(string&& name, unsigned score) {
|
void ScoresManager::inputScore(string name, unsigned score) {
|
||||||
auto ite = scores.begin();
|
auto ite = scores.begin();
|
||||||
while(ite!=scores.end()){
|
while(ite!=scores.end()){
|
||||||
if(score > ite->score) {
|
if(score > ite->score) {
|
||||||
scores.emplace(ite, name, score);
|
scores.emplace(ite, move(name), score);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++ite;
|
++ite;
|
||||||
}
|
}
|
||||||
if(ite==scores.end())scores.emplace(ite, name, score);
|
|
||||||
|
if(ite==scores.end())scores.emplace(ite, move(name), score);
|
||||||
|
|
||||||
if(scores.size()>SCORE_LIMIT)scores.erase(scores.begin()+SCORE_LIMIT);
|
if(scores.size()>SCORE_LIMIT)scores.erase(scores.begin()+SCORE_LIMIT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoreLink::ScoreLink(string&& name, unsigned int score) {
|
ScoreLink::ScoreLink(string name, unsigned int score) {
|
||||||
this->name = name;
|
this->name = move(name);
|
||||||
this->score = score;
|
this->score = score;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user