modified drawPlayer
This commit is contained in:
parent
31474894bc
commit
b4d23c13b0
@ -30,9 +30,14 @@ class GoodPixelManager : public PixelManager{
|
||||
void loadSprites(vector<Task>& tasks) override;
|
||||
|
||||
/*!
|
||||
* @brief sprite of the player
|
||||
* @brief sprite of the first player
|
||||
*/
|
||||
MySprite player;
|
||||
MySprite player1;
|
||||
|
||||
/*!
|
||||
* @brief sprite of the second player
|
||||
*/
|
||||
MySprite player2;
|
||||
|
||||
/*!
|
||||
* @brief sprite of the type A invader
|
||||
@ -67,7 +72,7 @@ class GoodPixelManager : public PixelManager{
|
||||
void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const override;
|
||||
void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const override;
|
||||
void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const override;
|
||||
void drawPlayer(unsigned x, unsigned width, const RGBAcolor& color) const override;
|
||||
void drawPlayer(playerID pID, unsigned x, unsigned width, const RGBAcolor& color) const override;
|
||||
void drawMissile(const Position& baseVector, unsigned width, const RGBAcolor& color) const override;
|
||||
void drawTorpedo(const Position& baseVector, unsigned width, const RGBAcolor& color) const override;
|
||||
void drawHeart(const Position& baseVector) const override;
|
||||
|
||||
@ -120,12 +120,13 @@ public:
|
||||
|
||||
/*!
|
||||
* @brief display a player on screen
|
||||
* @param[in] pID : the ID of the player to draw
|
||||
* @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;
|
||||
*/
|
||||
virtual void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||
virtual void drawPlayer(playerID pID, unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||
|
||||
/*!
|
||||
* @brief display a missile on screen
|
||||
|
||||
@ -49,7 +49,7 @@ void Game::displayAll(unsigned fps) const {
|
||||
|
||||
if(!players[i].isEliminated()){
|
||||
if(players[i].deathAnimCounter%2==0){
|
||||
pm->drawPlayer(players[i].x, confData.playersWidth, confData.playerDefs[i].color);
|
||||
pm->drawPlayer(i, players[i].x, confData.playersWidth, confData.playerDefs[i].color);
|
||||
}
|
||||
}
|
||||
// out of the condition, because we still need to display the falling heart
|
||||
|
||||
@ -56,7 +56,8 @@ void PixelManager::drawInvaderC(const Position& baseVector, unsigned size, const
|
||||
window << Rectangle(Position(35*scale, 65*scale)+baseVector, Position(65*scale, 72*scale)+baseVector, nsGraphics::KBlack);
|
||||
}
|
||||
|
||||
void PixelManager::drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const {
|
||||
// playerID argument is unused here, so we don't even give it a name
|
||||
void PixelManager::drawPlayer(playerID, unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const {
|
||||
width = width-10-10;
|
||||
width = width/2;
|
||||
window << Triangle(Position(0+x, 720), Position(5+x, 720), Position(5+x, 720-PLAYER_HEIGHT/2), color);
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
|
||||
void GoodPixelManager::loadSprites(vector<Task>& tasks) {
|
||||
PixelManager::loadSprites(tasks);
|
||||
ADD_SPRITE_TASK(player)
|
||||
ADD_SPRITE_TASK(player1)
|
||||
ADD_SPRITE_TASK(player2)
|
||||
ADD_SPRITE_TASK(invaderA)
|
||||
ADD_SPRITE_TASK(invaderB)
|
||||
ADD_SPRITE_TASK(invaderC)
|
||||
@ -27,8 +28,12 @@ void GoodPixelManager::drawInvaderC(const Position& baseVector, unsigned size, c
|
||||
drawSprite(invaderC, baseVector);
|
||||
}
|
||||
|
||||
void GoodPixelManager::drawPlayer(unsigned x, unsigned width, const RGBAcolor& color) const {
|
||||
drawSprite(player, Position(x, PLAYER_HEIGHT));
|
||||
void GoodPixelManager::drawPlayer(playerID pID, unsigned x, unsigned width, const RGBAcolor& color) const {
|
||||
if(pID==PLAYER1){
|
||||
drawSprite(player1, Position(x, PLAYER_HEIGHT));
|
||||
}else if (pID==PLAYER2){
|
||||
drawSprite(player2, Position(x, PLAYER_HEIGHT));
|
||||
}else throw runtime_error("Invalid player ID to draw : "+ to_string(pID));
|
||||
}
|
||||
|
||||
void GoodPixelManager::drawMissile(const Position& baseVector, unsigned width, const RGBAcolor& color) const {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user