本文整理汇总了C++中resetGame函数的典型用法代码示例。如果您正苦于以下问题:C++ resetGame函数的具体用法?C++ resetGame怎么用?C++ resetGame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resetGame函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: placeMove
int TicTacToe::play(bool _xTurn, int pos) {
bool win;
if(!isRightTurn(_xTurn)) {
return INVALID_TURN;
}
if(!isValidMove(pos)) {
return INVALID_MOVE;
}
placeMove(_xTurn,pos);
plotGame();
win = won(_xTurn);
xTurn = !xTurn;
if(win) {
resetGame();
return WIN;
}
else if(isFull()){
resetGame();
return OVER;
}
else {
return NO_WIN;
}
}
示例2: demo_menu
// glut menu callback
void demo_menu(int id)
{
switch(id)
{
case 1:
pauseBool = false;
if(!gameStarted)
{
start = std::chrono::high_resolution_clock::now();
gameStarted = true;
}
break;
case 2:
pauseBool = true;
break;
case 3:
resetGame();
break;
case 4:
resetGame();
scoreOne = 0;
scoreTwo = 0;
break;
case 5:
exit(0);
break;
}
glutPostRedisplay();
}
示例3: resetGame
void SdlDisplay::sdlMenuAction(bool multi)
{
if (index == 1)
{
freeall = true;
gameover = true;
resetGame();
sdlLauncher(false);
}
else if (index == 2)
{
freeall = true;
gameover = true;
resetGame();
sdlLauncher(true);
}
else if (index == 3)
{
freeall = true;
gameover = true;
resetGame();
if (multi)
sdlLauncher(true);
else
sdlLauncher(false);
}
}
示例4: game
Result game(int seed) {
Result result = {LOSE, 0};
srand(seed);
Block blocks[size*size];
int blocksLeft = 0;
resetGame(blocks, &blocksLeft, &result);
int index = 0;
int spawn = FALSE;
int quit = FALSE;
while (!quit) {
if (KEY_DOWN_NOW(BUTTON_UP)) {
if (moveBlocks(blocks, UP, &result.score, &blocksLeft, &result.outcome) && blocksLeft) {
spawn = TRUE;
}
while (KEY_DOWN_NOW(BUTTON_UP));
}
if (KEY_DOWN_NOW(BUTTON_DOWN)) {
if (moveBlocks(blocks, DOWN, &result.score, &blocksLeft, &result.outcome) && blocksLeft) {
spawn = TRUE;
}
while (KEY_DOWN_NOW(BUTTON_DOWN));
}
if (KEY_DOWN_NOW(BUTTON_LEFT)) {
if (moveBlocks(blocks, LEFT, &result.score, &blocksLeft, &result.outcome) && blocksLeft) {
spawn = TRUE;
}
while (KEY_DOWN_NOW(BUTTON_LEFT));
}
if (KEY_DOWN_NOW(BUTTON_RIGHT)) {
if (moveBlocks(blocks, RIGHT, &result.score, &blocksLeft, &result.outcome) && blocksLeft) {
spawn = TRUE;
}
while (KEY_DOWN_NOW(BUTTON_RIGHT));
}
if (spawn) {
index = spawnBlock(blocks, blocksLeft--);
result.score += 1<<blocks[index].num;
waitForVblank();
drawBlock(blocks, index);
updateScoreDisplay(result.score);
quit = !hasMoves(blocks);
spawn = FALSE;
}
if (KEY_DOWN_NOW(BUTTON_B)) {
quit = TRUE;
while (KEY_DOWN_NOW(BUTTON_B));
}
if (KEY_DOWN_NOW(BUTTON_SELECT)) {
resetGame(blocks, &blocksLeft, &result);
while (KEY_DOWN_NOW(BUTTON_SELECT));
}
}
//put a while loop here to check if game ends properly
return result;
}
示例5: while
void MenuServeur::processEvents()
{
sf::Event event;
while (mWindow.pollEvent(event))
{
if (event.type==sf::Event::KeyPressed)
{
switch(event.key.code)
{
case sf::Keyboard::Escape:
mWindow.close();
break;
case sf::Keyboard::Return: //retour menu
break;
case sf::Keyboard::R:
resetGame();
break;
}}
switch (event.type)
{
case sf::Event::MouseButtonPressed:
if (event.mouseButton.button == sf::Mouse::Left)
{
Square square(squareClicked(event.mouseButton.x,event.mouseButton.y));
if (square != UNKNOWN)
{
if (mBoard.addMove(mPlayer,square))
{
addSprite(square);
updateOutcome();
displayOutcome();
if (mOutcome == UNFINISHED)
swapPlayer();
else
// Xwin();
resetGame();
}
}
}
break;
case sf::Event::Closed:
mWindow.close();
break;
}
}
}
示例6: while
void Battleship::play() {
cout << endl << endl << "~~~~~~ WELCOME TO BATTLESHIPS ~~~~~~" << endl;
bool gameOver = false;
while (!gameOver) {
gameLoop();
cout << endl << "Do you want to try again? (Y/N)" << endl;
char tryAgain;
cin >> tryAgain;
if (tryAgain == 'Y') {
resetGame();
cout << endl << endl;
}
else if (tryAgain = 'N'){
gameOver = true;
}
else {
cout << "Your input was not understood. Ending game..." << endl;
gameOver = true;
}
}
cout << endl << "~~~~~~~ GAME OVER ~~~~~~~" << endl << endl;
}
示例7: resetGameLoadMapAddActors
void resetGameLoadMapAddActors( GameModel & game, PathGraph & pathgraph, GameView & view, GameViewSound & sound, ActorControllerKeyboard * & keyboardController, std::map< std::string, ActorControllerAI * > & aiControllers, std::map< std::string, float > & globalVariables, float gametime, const std::string & filename ) {
// delete ai controllers
for( std::map< std::string, ActorControllerAI * >::iterator iter = aiControllers.begin( ); iter != aiControllers.end( ); iter++ ) {
delete iter->second;
}
aiControllers.clear( );
// reset game
resetGame( game, pathgraph, view, sound );
setGameVars( game, globalVariables );
// load map
loadMap( game, pathgraph, view, sound, globalVariables, filename );
view.initBrushTextures( );
// add players
//addPlayer( game, keyboardController, globalVariables, gametime, "Player" );
addActor( game, keyboardController, globalVariables, gametime, "Player" );
for( int i = 0; i < 3; i++ ) {
aiControllers[ "AI-" + std::string( 1, (char)( i + 49 ) ) ] = new ActorControllerAI( &game, pathgraph );
//addAI( game, aiControllers[ "AI-" + std::string( 1, (char)( i + 49 ) ) ], globalVariables, gametime, "AI-" + std::string( 1, (char)( i + 49 ) ) );
addActor( game, aiControllers[ "AI-" + std::string( 1, (char)( i + 49 ) ) ], globalVariables, gametime, "AI-" + std::string( 1, (char)( i + 49 ) ) );
}
view.setCamera( &game.getActors( ).front( ) );
sound.setCamera( &game.getActors( ).front( ) );
}
示例8: if
void myGame::updateGameState()
{
timeInState+= frameTime; // keeps track of the time spent in each state of the display
if (gameStates == BEGIN && timeInState > 3.0)
{
gameStates = PLAY;
timeInState = 0;
}
else if (gameStates == PLAY && dotsRemaining == 0)
{
gameStates = END;
timeInState = 0;
}
else if (gameStates == END && timeInState > 3.0 ||
gameStates == END && input->isKeyDown(ENTER_KEY))
{
/*
dotsRemaining = rows * cols ;
for(int i=0;i<dots.getSize();i++){
dots.getArray()[i]->setVisible(true);
dots.getArray()[i]->setActive(true);
}
*/
resetGame();
player.setX(playerNS::X);
player.setY(playerNS::Y);
gameStates = BEGIN;
timeInState = 0;
}
}
示例9: isLevelDone
void isLevelDone()
{
int i, j;
// Verify
for (i=0; i!=LEVEL_SIDE; i++)
for (j=0; j!=LEVEL_SIDE; j++)
if (lvl.map[i][j].state == 1) return;
// Increment the instructions counter
for (i=0; i!=MATRIX_W; i++)
for (j=0; j!=MATRIX_H; j++)
if (game.func_matrix[i][j] > 0) game.instructions_count++;
setFadeMode(&main_fade,FADE_IN,0);
waitFadeDone();
// This was the last level... outro time.
if (nextLevel()) { game.state = OUTRO; return; }
// Else, reset game state; this is intro time.
resetGame();
stopProgram();
clearFuncMatrix();
game.state = GAME_INTRO;
}
示例10: mainloop
void mainloop(){
int esc = 1;
Stats* stats;
stats = initGame();
do{
system("CLS");
switch(esc){
case 0:
break;
case 1:
esc = menuPrincipal();
break;
case 11:
esc = menuNovoJogo(stats);
break;
case 111:
menuNovoJogador(stats);
esc /= 10;
break;
case 112:
seletorRodada(stats);
esc = novaPartida();
if (esc == 11) resetGame(stats);
break;
case 10:
case 110:
esc = 0;
break;
};
}while(esc!=0);
};
示例11: resetGame
//--------------------------------------------------------------
void testApp::keyReleased(int key)
{
//if the game is running
if(!gameOver)
{
if(key=='w')
{
//move up
player1.stopMoving();
}
if(key=='s')
{
//move down
player1.stopMoving();
}
if(key==' ')
{
//fire
player1.fire();
}
}
//if the game over screen is up
else
{
//reset the game when enter is pressed
if(key==OF_KEY_RETURN)
{
resetGame();
}
}
}
示例12: resetGame
void game::update(){
if(meny->getShowMeny()){//if meny is on.
meny->guiUpdate();//calls meny memeber function guiUpdate.
resetGame(); // resets the game over and over.
} else { //if meny is off.
ball->movementOfBall(updateTime);//move the ball with updatetime clock.
//Player pad movement.
if(fPlayer->getLeft()){//if player pad should move left.
fPlayer->moveLeft();//move player pad left.
}
if(fPlayer->getRight()){//if player pad should move right.
fPlayer->moveRight();//move player pad right.
}
if(boxesIsEmpty()){ //vector with boxes is empty
meny->winner(updateTime);//call winning text.
}
if(ball->checkIfDead()){//check if ball is dead(position under player pad).
fPlayer->loseLife();//removes a extra life.
if(fPlayer->getLife() >= 0){//if extra life is more/= to 0.
delete ball;//delete old ball
ball = new bounceBall();//alocate new ball.
}else{
meny->gameOver(updateTime);//show gameover text object.
}
}
collition();//check if ball collide with something.
}
}
示例13: resetGame
void Pacman::reset()
{
m_player.Lives = 3;
m_gameScore = 0;
resetGame();
}
示例14: updateScore
void updateScore(){
int ballPositionX = 10.0*(modelB[0][3]);
int leftWall = -130;
int rightWall = 130;
// Player 1 scores
if (ballPositionX >= rightWall){
score[0]++;
std::cout<<"Player 1 scored!\n";
std::cout<<"Score is "<<score[0]<<" : "<<score[1]<<"\n\n";
resetGame();
} // Player 2 scores
else if (ballPositionX <= leftWall){
score[1]++;
std::cout<<"Player 2 scored!\n";
std::cout<<"Score is "<<score[0]<<" : "<<score[1]<<"\n\n";
resetGame();
}
}
示例15: setFood
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if (!publicRelease){
if (key == 'f'){
setFood();
}
if (key == 'e'){
endGame();
}
if (key == 'c'){
captureScreen = !captureScreen;
return;
}
if (key == 'v'){
captureOneScreenshot = true;
}
if (key == 'p'){
debugPause = !debugPause;
}
if (key == 'm'){
debugMute = !debugMute;
}
if (key == 'r'){
resetGame();
}
}
snake.keyPressed(key);
if (onTitle){
resetGame();
//onTitle = true; //kill me
}
}