void ColoredCubeApp::updateGameState() { if(gamestate == title && (GetAsyncKeyState('E') & 0x8000)) { gamestate = controls; } if(gamestate == controls && (GetAsyncKeyState('G') & 0x8000)) { gamestate = level1; } if(gamestate == level1 && (currentKeys==totalKeys)) { gamestate = level2; reloadLevel(); } if(gamestate == level2 && goal) { gamestate = win; } if((gamestate == level1 || gamestate == level2) && player.getHealth() <= 0) { gamestate = gameover; } if((gamestate == gameover ||gamestate==win)&& (GetAsyncKeyState('E') & 0x8000)) { gamestate = title; } }
void GameFlow::slot_showLevelInfoDialog() { if (theDialogPtr) slot_clearDialog(); theDialogPtr = theRequestDialogItfPtr->showLevelInfo(); theDialogPtr->setProperty("levelName", theMainWindowPtr->theLevelPtr->theLevelName); theDialogPtr->setProperty("description", theMainWindowPtr->theLevelPtr->theLevelDescription); theDialogPtr->setProperty("author", theMainWindowPtr->theLevelPtr->theLevelAuthor); connect(theDialogPtr, SIGNAL(resetButton_clicked()), theMainWindowPtr, SLOT(reloadLevel())); connect(theDialogPtr, SIGNAL(okButton_clicked()), this, SLOT(slot_clearDialog())); }
void Environment::run(){ ((Fly*) entityMap.value(flyID))->move(); bool badAngle = false; if(!waitStart){ int tmpT = chrono.elapsed(); envTime currentTime = convertTime(tmpT); emit sendTime(currentTime); } if(getFly()->isInSlidingMod()){ getFly()->Boost(true); emit padBlock(); } if(getFly()->get_trigger().intersection(hitBox,sf::Color::Black)){ isSliding= false; if(!getFly()->isInSlidingMod()){ getFly()->Boost(false); } if(!badAngle && !isSliding){ badAngle = getFly()->slide(hitBox); isSliding = true; } if (badAngle) emit sigWall(); } if(((Fly*) entityMap.value(flyID))->get_trigger().intersection(hitBox,sf::Color::Red)){ // La Mort ! reloadLevel(); playerStat.insert("mort",playerStat.value("mort")+1); // bonusPurge(); // bonusLoader(level); } if(((Fly*) entityMap.value(flyID))->get_trigger().intersection(hitBox,sf::Color(0,255,0))){ if(((Fly*) entityMap.value(flyID))->get_trigger().intersection(hitBox,sf::Color(0,0,255)) && !isArrived){ emit sigWall(); getFly()->Boost(false); }else{ isArrived = true; } } if(((Fly*) entityMap.value(flyID))->get_trigger().isInSprite(hitBox,sf::Color(0,0,255)) && !waitStart && isArrived){ // ligne d'arrivee ! waitStart = true; isArrived = false; totalTime = chrono.elapsed(); if(totalTime < dataLoader.getBestTime()){ dataLoader.saveHighScore(QString("Data/level") + QString::number(level) + QString(".data"),timeToString(convertTime(totalTime))); emit sendTotalTime(convertTime(totalTime)); dataLoader.setBestTime(totalTime); } } if(((Fly*) entityMap.value(flyID))->get_trigger().isInSprite(hitBox,sf::Color::White) && waitStart){ // départ ! chrono.start(); waitStart = false; } // bpoint pt; // pt.first = entityMap.value(flyID)->get_x(); // pt.second = entityMap.value(flyID)->get_y(); // for(int i = 0; i < cacaIdList.size();i++){ // if(entityMap.value(cacaIdList[i])->get_trigger().isIN(pt.first,pt.second)){ // DM.remove(cacaIdList[i],pt.second); // /* if(entityMap.value(bonusIdList[i])->get_nom() == "caca") // playerStat.insert("score",playerStat.value("score")+100); // if(entityMap.value(bonusIdList[i])->get_nom() == "cacador") // playerStat.insert("score",playerStat.value("score")+1000); //*/ // entityMap.remove(cacaIdList[i]); // cacaIdList.remove(i); // cacaIdList.squeeze(); // } // } // for(int i = 0; i < cacadorIdList.size();i++){ // if(entityMap.value(cacadorIdList[i])->get_trigger().isIN(pt.first,pt.second)){ // DM.remove(cacadorIdList[i],pt.second); // /* if(entityMap.value(bonusIdList[i])->get_nom() == "caca") // playerStat.insert("score",playerStat.value("score")+100); // if(entityMap.value(bonusIdList[i])->get_nom() == "cacador") // playerStat.insert("score",playerStat.value("score")+1000); //*/ // entityMap.remove(cacadorIdList[i]); // cacadorIdList.remove(i); // cacadorIdList.squeeze(); // } // } DM.setEM(entityMap); emit sendDM(DM); emit sendMort(playerStat.value("mort")); emit sendScore(playerStat.value("score")); }