things
This commit is contained in:
parent
f2822815dd
commit
7b2eda8549
@ -80,50 +80,56 @@ public:
|
||||
explicit PixelManager(MinGL&);
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[in] baseVector :
|
||||
* @param[in] size :
|
||||
* @param[in] color :
|
||||
* @fn
|
||||
* @brief display a type A invader on screen
|
||||
* @param[in] baseVector : pixel coordinate of the invader
|
||||
* @param[in] size : size multiplicator of the invader
|
||||
* @param[in] color : color multiplicaror of the invader
|
||||
* @fn void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||
*/
|
||||
void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[in] baseVector :
|
||||
* @param[in] size :
|
||||
* @param[in] color :
|
||||
* @fn
|
||||
* @brief display a type B invader on screen
|
||||
* @param[in] baseVector : pixel coordinate of the invader
|
||||
* @param[in] size : size multiplicator of the invader
|
||||
* @param[in] color : color multiplicaror of the invader
|
||||
* @fn void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||
*/
|
||||
void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[in] baseVector
|
||||
* @param[in] size
|
||||
* @param[in] color
|
||||
* @fn
|
||||
* @brief display a type C invader on screen
|
||||
* @param[in] baseVector : pixel coordinate of the invader
|
||||
* @param[in] size : size multiplicator of the invader
|
||||
* @param[in] color : color multiplicaror of the invader
|
||||
* @fn void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||
*/
|
||||
void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
* @brief display a player on screen
|
||||
* @param[in] x : horizontal position of the player
|
||||
* @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;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
* @brief display a missile on screen
|
||||
* @param[in] baseVector : pixel coordinates of the missile
|
||||
* @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;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @param[]
|
||||
* @fn
|
||||
* @brief display a torpedo on screen
|
||||
* @param[in] baseVector : pixel coordinates of the torpedo
|
||||
* @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;
|
||||
|
||||
@ -171,10 +177,32 @@ public:
|
||||
*/
|
||||
void drawFPS(unsigned fps) const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
PlayMode showInitialMenu();
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
bool showDeathMenu();
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
unsigned getScreenHeight() const;
|
||||
|
||||
/*!
|
||||
* @brief
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
unsigned getScreenWidth() const;
|
||||
|
||||
/*!
|
||||
|
@ -21,13 +21,13 @@ using namespace std;
|
||||
struct ScoreLink{
|
||||
string name;
|
||||
unsigned score;
|
||||
ScoreLink(string&& name, unsigned score);
|
||||
ScoreLink(string name, unsigned score);
|
||||
};
|
||||
|
||||
class ScoresManager {
|
||||
public:
|
||||
vector<ScoreLink> scores;
|
||||
void inputScore(string&& name, unsigned score);
|
||||
void inputScore(string name, unsigned score);
|
||||
void readFile();
|
||||
void writeFile() const;
|
||||
};
|
||||
|
@ -14,6 +14,16 @@
|
||||
* (We need to explicitly specify the default constructor)*/
|
||||
#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 nsGraphics::RGBAcolor;
|
||||
|
@ -18,10 +18,12 @@ using namespace std;
|
||||
|
||||
// TODO changer tout les unsigned par des size_t dans les boucles
|
||||
int main(){
|
||||
DEBUG(cout << "Starting program" << endl)
|
||||
srand(time(NULL));
|
||||
|
||||
|
||||
Game g;
|
||||
g.managedGames();
|
||||
DEBUG(cout << "Finished program. Goodbye !" << endl)
|
||||
|
||||
return 0;
|
||||
}
|
@ -86,21 +86,23 @@ void ScoresManager::writeFile() const {
|
||||
/**
|
||||
* 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();
|
||||
while(ite!=scores.end()){
|
||||
if(score > ite->score) {
|
||||
scores.emplace(ite, name, score);
|
||||
scores.emplace(ite, move(name), score);
|
||||
break;
|
||||
}
|
||||
++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);
|
||||
|
||||
}
|
||||
|
||||
ScoreLink::ScoreLink(string&& name, unsigned int score) {
|
||||
this->name = name;
|
||||
ScoreLink::ScoreLink(string name, unsigned int score) {
|
||||
this->name = move(name);
|
||||
this->score = score;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user