b
This commit is contained in:
parent
f2984fffb8
commit
947665d306
@ -69,6 +69,7 @@ public:
|
||||
* @return
|
||||
* @fn
|
||||
*/
|
||||
|
||||
unsigned validColsNumber() const;
|
||||
unsigned randomValidCol() const;
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ void PixelManager::askPlayerNameMenu(playerID pID, string& name) {
|
||||
while (window.isOpen()){
|
||||
startFrame();
|
||||
drawSprite(menuBackground);
|
||||
displayText(Position(600,100),"Nom du joueur "+ string(1,pID));
|
||||
displayText(Position(600,100),"Nom du joueur "+to_string(pID+1));
|
||||
for (size_t i = 0; i < name.size(); ++i){
|
||||
displayText(Position(600+30*i,200),string(1,name[i]),(i == currentSelected) ? nsGraphics::KRed : nsGraphics::KWhite);
|
||||
}
|
||||
|
@ -64,6 +64,9 @@ void Game::initGame(){
|
||||
// we re-construct players objects, we don't have to clear all members and can rely on the construction value (set in .h file)
|
||||
players.clear();
|
||||
|
||||
missiles.clear();
|
||||
torpedos.clear();
|
||||
|
||||
if(playMode==PlayMode::SINGLE){
|
||||
players.resize(1);
|
||||
}else{
|
||||
|
@ -49,7 +49,8 @@ void Game::managePlayers(){
|
||||
}
|
||||
|
||||
bool Game::manageInvaders(){
|
||||
if(grid.empty())return false; // If there are no more invaders we don't need to manage them
|
||||
if(!areThereInvadersLeft())return false; // If there are no more invaders we don't need to manage them
|
||||
|
||||
// shoot
|
||||
if(fireCooldown==0) {
|
||||
fireCooldown = confData.invadersFireCooldown + rand() % 60;
|
||||
|
@ -58,7 +58,8 @@ bool Game::manageGod() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (grid.size() > god.thrownInvPosY && grid[god.thrownInvPosX][god.thrownInvPosY] != InvaderType::NONE) {
|
||||
if (grid[god.thrownInvPosX].size() > god.thrownInvPosY &&
|
||||
grid[god.thrownInvPosX][god.thrownInvPosY] != InvaderType::NONE) {
|
||||
god.thrownInvType = grid[god.thrownInvPosX][god.thrownInvPosY];
|
||||
grid[god.thrownInvPosX][god.thrownInvPosY] = InvaderType::NONE;
|
||||
}
|
||||
@ -113,6 +114,11 @@ bool Game::manageGod() {
|
||||
if (invaderPos.getY() + confData.invadersSize >= pm.getScreenWidth() ||
|
||||
(invaderPos.getX() < 0 || invaderPos.getX() + confData.invadersSize >= pm.getScreenWidth())) {
|
||||
touched = true;
|
||||
|
||||
/* there are no invaders in the grid anymore, and the one thrown just went out of bound
|
||||
* So... return true, the playere wins*/
|
||||
if(!areThereInvadersLeft())return true;
|
||||
|
||||
// check player collision
|
||||
} else if (invaderPos.getY() + confData.invadersSize >= pm.getScreenHeight() - PLAYER_HEIGHT) {
|
||||
for (Player &p: players) {
|
||||
@ -131,16 +137,13 @@ bool Game::manageGod() {
|
||||
if (touched) {
|
||||
god.state = GodState::WAIT;
|
||||
god.counter = 0;
|
||||
if(!areThereInvadersLeft())return true;
|
||||
}
|
||||
/*
|
||||
* we do not need to reset other members, they'll be treated as non-initialized
|
||||
* When we cycle back between states
|
||||
*/
|
||||
/* we do not need to reset other members, they'll be treated as non-initialized
|
||||
* When we cycle back between states*/
|
||||
|
||||
|
||||
// We could have optimized that, but it's more readable like this and hopefully the compiler will optimize it itself
|
||||
if(areThereInvadersLeft())return false;
|
||||
else return true;
|
||||
return false;
|
||||
}
|
||||
case GodState::YOLO: {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user