b
This commit is contained in:
parent
f2984fffb8
commit
947665d306
@ -69,6 +69,7 @@ public:
|
|||||||
* @return
|
* @return
|
||||||
* @fn
|
* @fn
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned validColsNumber() const;
|
unsigned validColsNumber() const;
|
||||||
unsigned randomValidCol() const;
|
unsigned randomValidCol() const;
|
||||||
};
|
};
|
||||||
|
@ -84,7 +84,7 @@ void PixelManager::askPlayerNameMenu(playerID pID, string& name) {
|
|||||||
while (window.isOpen()){
|
while (window.isOpen()){
|
||||||
startFrame();
|
startFrame();
|
||||||
drawSprite(menuBackground);
|
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){
|
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);
|
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)
|
// 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();
|
players.clear();
|
||||||
|
|
||||||
|
missiles.clear();
|
||||||
|
torpedos.clear();
|
||||||
|
|
||||||
if(playMode==PlayMode::SINGLE){
|
if(playMode==PlayMode::SINGLE){
|
||||||
players.resize(1);
|
players.resize(1);
|
||||||
}else{
|
}else{
|
||||||
|
@ -49,7 +49,8 @@ void Game::managePlayers(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Game::manageInvaders(){
|
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
|
// shoot
|
||||||
if(fireCooldown==0) {
|
if(fireCooldown==0) {
|
||||||
fireCooldown = confData.invadersFireCooldown + rand() % 60;
|
fireCooldown = confData.invadersFireCooldown + rand() % 60;
|
||||||
|
@ -58,7 +58,8 @@ bool Game::manageGod() {
|
|||||||
return false;
|
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];
|
god.thrownInvType = grid[god.thrownInvPosX][god.thrownInvPosY];
|
||||||
grid[god.thrownInvPosX][god.thrownInvPosY] = InvaderType::NONE;
|
grid[god.thrownInvPosX][god.thrownInvPosY] = InvaderType::NONE;
|
||||||
}
|
}
|
||||||
@ -113,6 +114,11 @@ bool Game::manageGod() {
|
|||||||
if (invaderPos.getY() + confData.invadersSize >= pm.getScreenWidth() ||
|
if (invaderPos.getY() + confData.invadersSize >= pm.getScreenWidth() ||
|
||||||
(invaderPos.getX() < 0 || invaderPos.getX() + confData.invadersSize >= pm.getScreenWidth())) {
|
(invaderPos.getX() < 0 || invaderPos.getX() + confData.invadersSize >= pm.getScreenWidth())) {
|
||||||
touched = true;
|
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
|
// check player collision
|
||||||
} else if (invaderPos.getY() + confData.invadersSize >= pm.getScreenHeight() - PLAYER_HEIGHT) {
|
} else if (invaderPos.getY() + confData.invadersSize >= pm.getScreenHeight() - PLAYER_HEIGHT) {
|
||||||
for (Player &p: players) {
|
for (Player &p: players) {
|
||||||
@ -131,16 +137,13 @@ bool Game::manageGod() {
|
|||||||
if (touched) {
|
if (touched) {
|
||||||
god.state = GodState::WAIT;
|
god.state = GodState::WAIT;
|
||||||
god.counter = 0;
|
god.counter = 0;
|
||||||
|
if(!areThereInvadersLeft())return true;
|
||||||
}
|
}
|
||||||
/*
|
/* we do not need to reset other members, they'll be treated as non-initialized
|
||||||
* we do not need to reset other members, they'll be treated as non-initialized
|
* When we cycle back between states*/
|
||||||
* 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
|
return false;
|
||||||
if(areThereInvadersLeft())return false;
|
|
||||||
else return true;
|
|
||||||
}
|
}
|
||||||
case GodState::YOLO: {
|
case GodState::YOLO: {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user