now compiles
This commit is contained in:
parent
d54543b5f6
commit
a2c9d40d4d
@ -45,11 +45,12 @@ private:
|
|||||||
void displayAll(unsigned fps) const;
|
void displayAll(unsigned fps) const;
|
||||||
void displayGod() const;
|
void displayGod() const;
|
||||||
void displayInvader(const Position& basePos, InvaderType type) const;
|
void displayInvader(const Position& basePos, InvaderType type) const;
|
||||||
|
void displayHearts(playerID) const;
|
||||||
|
|
||||||
|
|
||||||
// managers
|
// managers
|
||||||
void managePlayers();
|
void managePlayers();
|
||||||
void manageOnePlayer(unsigned);
|
void manageOnePlayer(playerID);
|
||||||
bool manageInvaders();
|
bool manageInvaders();
|
||||||
|
|
||||||
// collision things
|
// collision things
|
||||||
|
|||||||
@ -42,6 +42,8 @@ public:
|
|||||||
void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
void drawPlayer(unsigned x, 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;
|
||||||
void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
|
#define HEART_LENGTH 40
|
||||||
|
void drawHeart(const Position& baseVector) const;
|
||||||
void drawSprite(const nsGui::Sprite& sprite, const Position& pos) const;
|
void drawSprite(const nsGui::Sprite& sprite, const Position& pos) const;
|
||||||
void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color);
|
void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color);
|
||||||
// TODO remove because unused ?
|
// TODO remove because unused ?
|
||||||
|
|||||||
@ -24,7 +24,9 @@ enum class WinValue{
|
|||||||
|
|
||||||
|
|
||||||
typedef nsGraphics::Vec2D Position;
|
typedef nsGraphics::Vec2D Position;
|
||||||
typedef unsigned playerID; // 0 for player 1, 1 for player 2
|
typedef unsigned playerID;
|
||||||
|
#define PLAYER1 0
|
||||||
|
#define PLAYER2 1
|
||||||
|
|
||||||
// didn't want to use Position because of the semantic with x and y
|
// didn't want to use Position because of the semantic with x and y
|
||||||
bool areLinesColliding(unsigned start1, unsigned end1, unsigned start2, unsigned end2);
|
bool areLinesColliding(unsigned start1, unsigned end1, unsigned start2, unsigned end2);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ PixelManager::PixelManager(MinGL& a) : window(a) {
|
|||||||
window.initGraphic();
|
window.initGraphic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawHeart(MinGL& window, const Position& baseVector){
|
void PixelManager::drawHeart(const Position& baseVector) const {
|
||||||
window << Circle(Position(10, 10)+baseVector,10, nsGraphics::KRed);
|
window << Circle(Position(10, 10)+baseVector,10, nsGraphics::KRed);
|
||||||
window << Circle(Position(30, 10)+baseVector,10, nsGraphics::KRed);
|
window << Circle(Position(30, 10)+baseVector,10, nsGraphics::KRed);
|
||||||
window << Triangle(Position(0,10)+baseVector,Position(40,10)+baseVector,Position(20,40)+baseVector,nsGraphics::KRed);
|
window << Triangle(Position(0,10)+baseVector,Position(40,10)+baseVector,Position(20,40)+baseVector,nsGraphics::KRed);
|
||||||
@ -128,7 +128,7 @@ void PixelManager::displayText(const Position& pos, const string& text,const nsG
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PixelManager::drawFPS(unsigned fps) const {
|
void PixelManager::drawFPS(unsigned fps) const {
|
||||||
window << Text(Position(getScreenWidth()-100, 10), "FPS : "+ to_string(fps), nsGraphics::KWhite);
|
window << Text(Position(getScreenWidth()-200, 10), "FPS : "+ to_string(fps), nsGraphics::KWhite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,14 +23,32 @@ void Game::displayAll(unsigned fps) const {
|
|||||||
pm.drawTorpedo(tor, confData.torpedosWidth, confData.torpedosColor);
|
pm.drawTorpedo(tor, confData.torpedosWidth, confData.torpedosColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i=0;i<players.size();++i){
|
|
||||||
pm.drawPlayer(players[i].x, confData.playersWidth, confData.playerDefs[i].color);
|
|
||||||
}
|
|
||||||
|
|
||||||
displayGod();
|
displayGod();
|
||||||
|
|
||||||
pm.drawFPS(fps);
|
pm.drawFPS(fps);
|
||||||
|
|
||||||
|
|
||||||
|
for(size_t i=0;i<players.size();++i){
|
||||||
|
pm.drawPlayer(players[i].x, confData.playersWidth, confData.playerDefs[i].color);
|
||||||
|
}
|
||||||
|
|
||||||
|
// As said before, the player loop is an illusion, 2 players max
|
||||||
|
for(unsigned i=0;i<players[0].lives;++i){
|
||||||
|
|
||||||
|
}
|
||||||
|
pm.drawHeart(Position(0, 70));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::displayHearts(playerID pID) const {
|
||||||
|
unsigned baseX;
|
||||||
|
if(pID==PLAYER1)baseX = 0;
|
||||||
|
else baseX = pm.getScreenWidth()-HEART_LENGTH;
|
||||||
|
|
||||||
|
unsigned y = GOD_BENCH_SIZE+5;
|
||||||
|
for(unsigned i=0;i<players[pID].lives;++i){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::displayInvader(const Position& pos, InvaderType type) const {
|
void Game::displayInvader(const Position& pos, InvaderType type) const {
|
||||||
|
|||||||
@ -67,8 +67,9 @@ bool Game::manageGod() {
|
|||||||
|
|
||||||
|
|
||||||
playerID target;
|
playerID target;
|
||||||
if (players.size() == 1)target = 0; // don't want to use random if not needed
|
if (players.size() == 1)target = PLAYER1; // don't want to use random if not needed
|
||||||
else target = rand() % players.size();
|
else target = rand() % players.size();
|
||||||
|
|
||||||
Position playerMiddlePos(players[target].x + confData.playersWidth / 2,
|
Position playerMiddlePos(players[target].x + confData.playersWidth / 2,
|
||||||
pm.getScreenHeight() - PLAYER_HEIGHT / 2);
|
pm.getScreenHeight() - PLAYER_HEIGHT / 2);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user