background + score support but the true one
This commit is contained in:
parent
8dc711bd2b
commit
bffc3bf04c
@ -18,7 +18,8 @@ public:
|
|||||||
void drawPlayer(const nsGraphics::Vec2D& baseVector, unsigned width, const nsGraphics::RGBAcolor &color);
|
void drawPlayer(const nsGraphics::Vec2D& baseVector, unsigned width, const nsGraphics::RGBAcolor &color);
|
||||||
void drawTorpedo(const nsGraphics::Vec2D& baseVector, unsigned width, const nsGraphics::RGBAcolor& color);
|
void drawTorpedo(const nsGraphics::Vec2D& baseVector, unsigned width, const nsGraphics::RGBAcolor& color);
|
||||||
void drawMissile(const nsGraphics::Vec2D& baseVector, unsigned width, const nsGraphics::RGBAcolor& color);
|
void drawMissile(const nsGraphics::Vec2D& baseVector, unsigned width, const nsGraphics::RGBAcolor& color);
|
||||||
void drawSprite(const nsGraphics::Vec2D& baseVector, const std::string& spritePath);
|
nsGui::Sprite background = nsGui::Sprite("./assets/bg.sl2", nsGraphics::Vec2D(0,0)); // you cant create an empty sprite for some reasons
|
||||||
|
void drawBackground();
|
||||||
|
|
||||||
unsigned showInitialMenu();
|
unsigned showInitialMenu();
|
||||||
unsigned showDeathMenu();
|
unsigned showDeathMenu();
|
||||||
@ -26,6 +27,7 @@ public:
|
|||||||
unsigned getScreenWidth();
|
unsigned getScreenWidth();
|
||||||
void startFrame();
|
void startFrame();
|
||||||
void endFrame();
|
void endFrame();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ void Game::managedGames() {
|
|||||||
playMode = initialMenuHandler();
|
playMode = initialMenuHandler();
|
||||||
}else{
|
}else{
|
||||||
playGame(); // will read the playMode
|
playGame(); // will read the playMode
|
||||||
|
cout << players[0].score << endl; // will remove
|
||||||
cout << "END OF GAME" << endl;
|
cout << "END OF GAME" << endl;
|
||||||
break; // TODO remove
|
break; // TODO remove
|
||||||
if(!deathMenuHandler()) playMode = NONE; // back to the main menu
|
if(!deathMenuHandler()) playMode = NONE; // back to the main menu
|
||||||
@ -87,7 +88,6 @@ WinValue Game::playGame(){ // returns when game is finished
|
|||||||
players[0].x = confData.startXPosition;
|
players[0].x = confData.startXPosition;
|
||||||
|
|
||||||
basePos = position(0,0);
|
basePos = position(0,0);
|
||||||
|
|
||||||
// GAMELOOP
|
// GAMELOOP
|
||||||
|
|
||||||
#define FPS 1000
|
#define FPS 1000
|
||||||
@ -120,6 +120,7 @@ WinValue Game::playGame(){ // returns when game is finished
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void Game::display() {
|
void Game::display() {
|
||||||
|
pm.drawBackground();
|
||||||
for (unsigned i = 0; i < this->grid.size(); ++i){
|
for (unsigned i = 0; i < this->grid.size(); ++i){
|
||||||
for (unsigned j = 0; j < this->grid[i].size(); ++j){
|
for (unsigned j = 0; j < this->grid[i].size(); ++j){
|
||||||
nsGraphics::Vec2D vec(
|
nsGraphics::Vec2D vec(
|
||||||
|
@ -161,6 +161,7 @@ bool Game::checkTorpedosAndInvaders() {
|
|||||||
}
|
}
|
||||||
if(i==grid.size()) ++tor_ite;
|
if(i==grid.size()) ++tor_ite;
|
||||||
else{
|
else{
|
||||||
|
players[tor_ite->owner].score += 100;
|
||||||
torpedos.erase(tor_ite);
|
torpedos.erase(tor_ite);
|
||||||
grid[i].pop_back();
|
grid[i].pop_back();
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,8 @@ void PixelManager::drawTorpedo(const nsGraphics::Vec2D& baseVector, unsigned wid
|
|||||||
window << nsShape::Rectangle(baseVector, baseVector+position(width, width*PROJ_LENGTH_FACTOR), color);
|
window << nsShape::Rectangle(baseVector, baseVector+position(width, width*PROJ_LENGTH_FACTOR), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelManager::drawSprite(const nsGraphics::Vec2D& baseVector, const std::string& spritePath){
|
void PixelManager::drawBackground(){
|
||||||
nsGui::Sprite sprite(spritePath,baseVector);
|
background.draw(window);
|
||||||
sprite.draw(window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned PixelManager::showInitialMenu(){
|
unsigned PixelManager::showInitialMenu(){
|
||||||
|
Loading…
Reference in New Issue
Block a user