• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ resetGame函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中resetGame函数的典型用法代码示例。如果您正苦于以下问题:C++ resetGame函数的具体用法?C++ resetGame怎么用?C++ resetGame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了resetGame函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
	}
}
开发者ID:zydeon,项目名称:tictactoe,代码行数:30,代码来源:TicTacToe.cpp


示例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();
}
开发者ID:alexwardCS480,项目名称:CS480Ward,代码行数:34,代码来源:main.cpp


示例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);
    }
}
开发者ID:bogardt,项目名称:mySnake,代码行数:27,代码来源:SdlDisplay.cpp


示例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;
}
开发者ID:dong-brian,项目名称:2048Plus,代码行数:55,代码来源:game.c


示例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;
    }
  }
}
开发者ID:othmane123,项目名称:ProjetMorpion,代码行数:49,代码来源:MenuServeur.cpp


示例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;
}
开发者ID:JMulligan94,项目名称:TutorialLessons,代码行数:25,代码来源:Battleship.cpp


示例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( ) );
}
开发者ID:stephenlombardi,项目名称:icggame,代码行数:26,代码来源:GameSetup.cpp


示例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;
	}
}
开发者ID:charliemathews,项目名称:pac-man,代码行数:33,代码来源:myGame.cpp


示例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;
}
开发者ID:libcg,项目名称:PSP_Bot,代码行数:26,代码来源:game_ingame.c


示例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);
};
开发者ID:bestknighter,项目名称:PokerJTC,代码行数:31,代码来源:GameLogic.c


示例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();
		}
	}
}
开发者ID:EdmundLewry,项目名称:AAVMain,代码行数:32,代码来源:testApp.cpp


示例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.
	} 
}
开发者ID:mejan,项目名称:SFML-break-out-game,代码行数:30,代码来源:game.cpp


示例13: resetGame

void Pacman::reset()
{
	m_player.Lives = 3;
	m_gameScore = 0;

	resetGame();
}
开发者ID:TheIllusionistMirage,项目名称:SFML2-Game,代码行数:7,代码来源:PacmanController.cpp


示例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();
	}		
}
开发者ID:FallDownT,项目名称:CS452-PROJECT1,代码行数:18,代码来源:project1.cpp


示例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
    }
    
    
}
开发者ID:andymasteroffish,项目名称:noise_snake,代码行数:45,代码来源:ofApp.cpp


示例16: main

void main(void) {
  DisableInterrupts;
	initializations(); 		  			 		  		
	EnableInterrupts;
  
  turnOffLEDs();
  // reset game on startup
  resetGame();
  
  TC7 = 15000;            //set up TIM TC7 to generate 0.1 ms interrupt rate
  for(;;) {
    displayBoard();
    
    
    if (interuptFlag) {
       tickCounter++;
       ticksSinceLastEvolution++;  	
  
       if (ticksSinceLastEvolution >= TICKS_BETWEEN_EVOLUTIONS) {
         ticksSinceLastEvolution = 0;
         evolveFlag = 1;
       }  
    }
    
    if (evolveFlag) {
      evolveFlag = 0;
      evolve();
    }
    
    if (boardsAreSame == 1) {
      resetGame();
    }
  
    // check to see if the user would like to reset the game (presses right push button)
    if (rghtpb == 1) {
      rghtpb = 0;
      resetGame();
    }
    
  
    _FEED_COP(); /* feeds the watchdog timer */
  } /* loop forever */
  /* make sure that you never leave main */
}
开发者ID:grantgumina,项目名称:ece362project,代码行数:44,代码来源:main.c


示例17: QMainWindow

start::start(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::start)
{
    ui->setupUi(this);
    resDialog=new result;
    Game=new game(this,resDialog);
    connect(resDialog,SIGNAL(reset()),this,SLOT(resetGame()));
    this->setCentralWidget(Game);
}
开发者ID:yakiyang,项目名称:lab7,代码行数:10,代码来源:start.cpp


示例18: onGameMain

State onGameMain(Game* game) {
	/*IGNORE*/
	int choice = 0;
	char filename[255];
	printGameMenu(game);
	choice = getInput();
	/* 
	"0. Restart a new game"
	"1. Load from a old game"
	"2. Save log"
	"3. Save this game"
	"4. Allow redo [%s]"
	"5. Allow illegal move [%s]"
	"6. Select default opponent [%s]"
	"7. Select default difficulty"
	"8. Return to the game"
	"9. Exit"
	*/
	switch(choice) {
	case 0:
		resetGame(game);
		return NewGame;
	case 1:
		/*loadGame(game);
		*/return NewGame;
	case 2:
		printf("Enter the file name you want to save \n");
		scanf("%s", filename);
		saveLog(game, filename);
		break;
	case 3:
		/*saveGame(game);
		*/break;
	case 4:
		game->setting->allowRedo ^= 1;
		break;
	case 5:
		game->setting->allowIllegalMove ^= 1;
		break;
	case 6:
		selectOpponent(game);
		break;
	case 7:
		selectDifficulty(game);
		break;
	case 8:
		return TurnPlayer;
	case 9:
		return Exit;
	default:
		return GameMenu;
	}
	return GameMenu;
}
开发者ID:cfj2k5,项目名称:Chess,代码行数:54,代码来源:GameMain.c


示例19: initState

//---------------------------------------------------------------------------------
// Name: enter() 
//---------------------------------------------------------------------------------
void GameplayState::enter(App * app)
{
    initState();
    
    BATTLE_CITY->loadMap( getNextMapNum() );
    setMapFrame();

    resetGame();
    incTimesPlayed();
    
    APP_EVENT( GAME_STARTED );
}
开发者ID:viktormoskalenko,项目名称:battle_city,代码行数:15,代码来源:gameplay_state.cpp


示例20: savecurrentSettings

void EmuSettings::resetButtonClicked()
	{
    if( settingsChanged )
    	{
		savecurrentSettings();
		emit( updateSettings(gpspsettings) );
		settingsChanged = false;
    	}
    
	if( romloaded )
		emit( resetGame() );
	}
开发者ID:xc700,项目名称:gpSP4Symbian,代码行数:12,代码来源:emusettings.cpp



注:本文中的resetGame函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ resetMiningButton函数代码示例发布时间:2022-05-30
下一篇:
C++ resetDefinition函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap