Ejemplo n.º 1
0
void			one_player(char **grid, int line, int col)
{
	int			token;
	int			i;

	i = who_begin();
	while (++i < line * col)
	{
		if (i == 0)
			display(grid);
		i % 2 == 1 ? (token = ai(grid, col))
			: (token = get_token(ft_strlen(grid[0]) + 1, 'X'));
		if (token > -1)
		{
			grid = place_token(grid, token, i);
			display(grid);
			if (test_win(grid, token) == 1)
			{
				victory(grid, token);
				return ;
			}
		}
		else
			i--;
	}
	ft_putendl("\n\nMatch nul\n");
}
Ejemplo n.º 2
0
// 处理输入槽
void WdgGuess::processInput(const QString &text)
{
	int i;
	Q_UNUSED(text); // 未使用的参数,避免产生编译警告
	QLineEdit *edit = (QLineEdit *)sender(); // 得到信号的发送者
	if (!edit) return;
	// 查找信号的发送者是哪一个编辑框
	for (i = 0; i < nrNum && edit == editNum[times][i]; i++) {}
	if (i == nrNum) return; // 未找到,返回
	// 查找本行内有没有未输入的编辑框
	for (i = 0; i < nrNum && !editNum[times][i]->text().isEmpty(); i++) {}
	if (i == nrNum) { // 没有未输入的编辑框,说明本次尝试已结束
		endThisTime(); // 结束本次尝试
		if (showStat()) { // 显示统计结果,如果成功
			victory(); // 成功
			return;
		}
		times++; // 尝试次数增加
		if (times == nrTimes) { // 如果尝试次数达到限定次数,说明失败
			failed(); // 失败
			return;
		} else {
			beginThisTime(); // 开始本次尝试(尝试次数已增加)
		}
	} else { // 还有未输入的编辑框
		editNum[times][i]->setFocus(); // 将焦点放在未输入的编辑框上
	}
}
Ejemplo n.º 3
0
void	puissance4(t_grid *grid)
{
	int		end;
	int		move;
	int		player;
	int		result;
	int		nbcoup;

	end = 0;
	move = -1;
	player = (ft_rand() % 2) + 1;
	result = 0;
	nbcoup = grid->width * grid->height;
	while (end == 0 && nbcoup > 0)
	{
		put_prompt(player, grid);
		if ((move = get_move(player, grid)) == -1)
			return ;
		if ((result = put_tocken(grid, move, player)) == 0)
		{
			player = (player == 1 ? 2 : 1);
			nbcoup--;
		}
		else if (result == 2)
		{
			victory(player, grid);
			end = 1;
		}
	}
	if (nbcoup == 0)
		ft_printf("Draw\n");
}
Ejemplo n.º 4
0
void BaseMap::update(float dt)
{
	updateGoldAndLife();
	if(isStart && isEnd && GameManager::getInstance()->monsterVector.size() == 0)
	{
		isStart = false;
		isEnd = false;
		victory();
	}
}
Ejemplo n.º 5
0
int battle(struct player* hero, struct creature *enemy)
{
	int act;

	if (enemy -> hp == 200)
	{
		script_speaking("Necromancer", 1, "How dare you, mere human, interfere in my great plans!");
		script_speaking("Hero", 1, "Oh, don't worry. Nothing personal, really. I just like beeing a thorn in someone's side.");
		script_speaking("Necromancer", 1, "Fool! That was your last mistake! You won't leave this place alive!");
		script_speaking("Hero", 2, "Yeah-yeah, whatever you say, pal.", "(to himself) It's showtime!");
	}

	while (1)
	{
		printf("Potions left: %d\n", hero -> potions);
		printf("What should we do???\n");
		printf("HP: %d/%d %s's HP:%d\n", hero -> hp, hero -> max_hp, enemy -> name, enemy -> hp);
		printf("1.Attack\n");
		printf("2.Use potion / +50 HP\n");
		printf("3.Leave the battle\n");
		scanf("%d",&act);
		system("clear");
		switch (act)
		{
			case 1: hit(hero, enemy);
					if (hero -> hp <= 0)
					{
						printf("Bad end!\nGame over...\n");
						return 2;
					}
					if (enemy -> hp <= 0)
					{
						victory(hero, enemy);
						return 0;
					}
					break;
			case 2: heal( hero );
					break;
			case 3:
				if (enemy -> exp != 40)
					return 1;
				else
					printf("Cannot flee from this battle...\n");
				break;
			default:
				printf("Choose action form one of the mentioned above\n");
		}
	}
	return 0;
}
Ejemplo n.º 6
0
void main()
{
	set();
	while (1)
	{
		if (!chkReverse()) break;
		marking();
		draw();
		if (turn == WHITE) //input_u();
			input_key();
		else input_c();
		if (chk_end()) break;
		chturn();
	}
	victory();
}
Ejemplo n.º 7
0
/**
 * Process 'a' battle command where client p is attacking.
 */
int regatk(struct client *p){
    char outbuf[512];
    srand((unsigned) time(NULL)); //Initialize random number generator
    
    //randomize regular attack between 2-6
    int atk = (rand() % (6+1-2))+2;
    (p->partner)->hp -= atk;
    /* Check for game winning condition, opponent hp < 0 */
    if (((p->partner)->hp) <= 0) {
        return victory(p); //-1 to indicate a victory for battlecmd function
    }
    else {
        sprintf(outbuf, "\nYou hit %s for %d damage!\r\n", (p->partner)->name, atk);
        write(p->fd, outbuf, strlen(outbuf));
        //write to opponent how much they lost
        sprintf(outbuf, "%s hits you for %d damage!\r\n", p->name, atk);
        write((p->partner)->fd, outbuf, strlen(outbuf));
    }

    return 0;
}
Ejemplo n.º 8
0
/**
 * Process 'p' battle command where client p is attacking.
 */
int poweratk(struct client *p){
    char outbuf[512];
    srand((unsigned) time(NULL));
    
    p->power -= 1;
    int atk = (rand() % (6+1-2))+2;
    int chance = rand() % 2; //50% chance of hitting, rand value 0 to 1
    if (chance == 1) {
        (p->partner)->hp -= 3*atk;
    }
    else {
        //attack misses nothing happens to hp
        atk = 0;
    }

    if (((p->partner)->hp ) <= 0) {
        return victory(p); //-1 to indicate a victory for battlecmd function
    }
    else {
        if (atk == 0) { //powermove missed
            sprintf(outbuf, "\nYou missed!\r\n");
            write(p->fd, outbuf, strlen(outbuf));

            sprintf(outbuf, "%s missed you!\r\n", p->name);
            write((p->partner)->fd, outbuf, strlen(outbuf));
        }
        else {
            sprintf(outbuf, "\nYou hit %s for %d damage!\r\n", (p->partner)->name, 3*atk);
            write(p->fd, outbuf, strlen(outbuf));
            
            //write to opponent how much they lost
            sprintf(outbuf, "%s powermoves you for %d damage!\r\n", p->name, 3*atk);
            write((p->partner)->fd, outbuf, strlen(outbuf));
        }
    }

    return 0;

}
Ejemplo n.º 9
0
/*
    This is the render loop
    At this point, you should know exactly what to draw onto the screen.
    Just draw it!
    To get an idea of the values for colours, look at console.h and the URL listed there
*/
void render()
{
    clearScreen();                      // clears the current screen and draw from scratch 
	switch (g_eGameState) {
	case SPLASH: splash();              // splash screen
		break;
	case TITLE: titlescreen();          // title screen
		break;
    case VICTORY: victory();            // victory screen
        break;
    case CREDITS: credits();            // credits & statistics screen
        break;
    case PAUSE: pausemenu();            // pause screen
        break;
    case CLASSSELECT: classSelect();    // class selection screen
        break;
	case GAME: renderGame();            // Game screen
		break;
	case GAMEOVER: gameend();           // Retry screen
		break;
	}
	renderToScreen();// dump the contents of the buffer to the screen, one frame worth of game
}
Ejemplo n.º 10
0
void MazePlugin::syscall(State *s, int status, int syscallNo, int valueOfa0) {
   Q_UNUSED(status);

   switch(syscallNo) {
      case S_MAZE_INIT:
         s->setRegister(v0, init_maze(s));
         break;
      case S_MAZE_DEFEAT:
         defeat();
         break;
      case S_MAZE_VICTORY:
         victory();
         break;
      case S_MAZE_IS_GOAL:
         s->setRegister(v0, is_goal(s, valueOfa0));
         break;
      case S_MAZE_NEIGHBOR:
         {
            int results[4];
            get_neighbors(s, valueOfa0, results);
            unsigned int addr = s->getRegister(a1);

            for(int i = 0; i < 4; ++i)
               s->setMemoryWord(addr + (i << 2), results[i]);
         }
         break;
      case S_MAZE_DRAW_ARROW:
         draw_arrow(s, status, valueOfa0, s->getRegister(a1));
         break;
      case S_MAZE_IS_SEARCHED:
         s->setRegister(v0, is_searched(s, valueOfa0));
         break;
      default:
         break;
   }
}
Ejemplo n.º 11
0
Archivo: ai.c Proyecto: ghuysmans/fiar
//https://en.wikipedia.org/wiki/Negamax#Negamax_with_alpha_beta_pruning
int negamax(Game *game, int alpha, int beta, int depth, int *best) {
	int j; //current column
	int cut = 0; //did we get a CUT at some point?
	int best_score = DEFEAT; //best score we've seen so far
	int one_decision = 0; //have we ever taken a real decision?
	if (!depth)
		return CUT; //the search space is often way too large
	for (j=0; j<game->cols; j++) {
		if (can_play(game, j)) {
			play(game, j); {
				int v;
				if (victory(game, j)) //this has to be done here
					v = VICTORY; //since the last move is unknown...
				else {
					int trash; //we don't care about the next move
					v = -negamax(game, -beta, -alpha, depth-1, &trash);
				}
				if (-v == CUT) //check the original return value
					cut = 1;
				else {
					v /= 2; //so, longer paths are less interesting
					one_decision = 1;
					//update best* variables
					if (best_score < v) {
						best_score = v;
						*best = j;
					}
					alpha = MAX(alpha, v);
				}
			} undo(game, j);
			if (alpha >= beta)
				break; //prune
		}
	}
	return (!one_decision && cut) ? CUT : best_score;
}
Ejemplo n.º 12
0
/*! \brief Carries out actions if snake collided with something.
 * Precondition: The Snake is moved by a directional key press or a timer event.
 * Postcondition: Specific action carried out according to what the snake collided with.*/
void Game::checkCollision()
{
	/* Prevents game from crashing at when the snake is bigger than 318 SnakeBlocks */
	// If snake takes up 98% of screen, then VICTORY!!!
	if(growCount == 315)
		{victory();}

	if(winSpawn)
	{
		//If Snake collides with foodWinner (Linux logo), end game and set up victory screen
		if ((foodWinner->getRect()).intersects(snake->getRect())) 
		{
			victory();
		}
	}
	else if(deathSpawn)
	{
		//If Snake collides with specialFood (Windows 8 logo), kill timer and set up the Blue screen of death
		if ((specialFood->getRect()).intersects(snake->getRect())) 
		{
			blueScreenDeath();
		}
	}
	

	if(spawnWinnerCount % 1000 == 0 && spawnWinnerCount != 0 && doOneTime)
	{
		// set up variables to paint foodWinner (Linux logo)
		deathSpawn = FALSE;
		winSpawn = TRUE;
		doOneTime = FALSE;

		// move foodWinner (Linux logo) to new location and make sure it is not on top of anything
		do{
			foodWinner->moveFood(food);		  	

		}while(snake->checkBadFood(foodWinner));
	}
	else if(growCount%10==0 && growCount != 0 && doOneTime)
	{
		// set up variables to paint specialFood (Windows 8 logo)
		deathSpawn = TRUE;
		doOneTime = FALSE;

		/* Resolving specialFood respawn issues */
		growCount++; //Prevents respawn of specialFood, if snake hasn't grown again after 100 paints
		fixCount = TRUE; //fixs growCount next grow

		// move specialFood (Windows 8 logo) to new location and make sure it is not on top of anything
		do{
			specialFood->moveFood(food);		  	

		}while(snake->checkBadFood(specialFood));
	}

	// If snake collides with food (Apple logos), then switch food images, move food, grow snake, and increase points
	if ((food->getRect()).intersects(snake->getRect())) 
	{   	
		// Sets up variable to switch food images
		switchFood++;// increments Apple logo switcher
	    	switchFood %= 2; // if Apple logo switch equals 2, set it back to zero

		// move food (Apple logos) to new location and make sure it is not on top of anything
		do{
			if(winSpawn)
				food->moveFood(foodWinner,switchFood);
			else if(deathSpawn)
				food->moveFood(specialFood,switchFood);
			else
	  			food->moveFood(switchFood);

		}while(snake->checkBadFood(food));

		// Grows snake
		snake->grow();
		growCount++; // increases grow count
		
		/* Resolving specialFood respawn issues */
		// Fixes growCount if it was incremented earlier 
		if(fixCount == TRUE) 
		{
			growCount--;
			fixCount = FALSE;
		}

		// Increases points
		points += 7*pointMulti;
	}

	// If snake head (front of snake) collides with the rest of 
	// the snake, stop the game and display the Game Over screen.
	if(snake->checkCollision()) 
		{stopGame();}

	// If wrapAround is disabled and the snake head (front of snake) 
	// goes off screen, stop the game and display the Game Over screen.
	if(wrapAround == FALSE)	
	{
		if(snake->hitsWall())
			{stopGame();}
	}
}
Ejemplo n.º 13
0
/*! \brief Carries out the required actions for the specific key.
 * Precondition: a QKeyEvent is called. (a key is pressed)
 * Postcondition: Actions for specified key are carried out.
 * \param *event QT event pointer*/
void Game::keyPressEvent(QKeyEvent *event)
{
    switch (event->key()) 
    {
    	case Qt::Key_Left: // Left arrow was pressed
       	{  
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame();  // set up variables to end game and dispaly game over screen
		}
		else if(!introPrompt1 && !introPrompt2) 
		{
			if(paused)
				{pauseGame();} // unpause game

			if(lastDir != 'L' && gameStarted)
			{
				snake->goLeft(wrapAround); // Move snake left one block
				checkCollision(); // Check if snake collided with anything
				changedDir = TRUE; // Set changedDir  to true
				lastDir = 'L'; // Set lastDir to 'L'
  				repaint(); // calls a paint event
			}


		}
       	}
	break;

    	case Qt::Key_Right: // Right arrow was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
		else if(!introPrompt1 && !introPrompt2)
		{
			if(paused)
				{pauseGame();} // unpause game

			if(lastDir != 'R' && gameStarted)
			{
				snake->goRight(wrapAround); // Move snake right one block
				checkCollision(); // Check if snake collided with anything
				changedDir = TRUE; // Set changedDir  to true
				lastDir = 'R'; // Set lastDir to 'R'
				repaint(); // calls a paint event
			}
		}
        }
        break;

    	case Qt::Key_Up: // Up arrow was pressed
       	{  
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
		else if(!introPrompt1 && !introPrompt2)
		{
			if(paused)
				{pauseGame();} // unpause game

			if(lastDir != 'U' && gameStarted)
			{
				snake->goUp(wrapAround); // Move snake Up one block
				checkCollision(); // Check if snake collided with anything
				changedDir = TRUE; // Set changedDir  to true
				lastDir = 'U'; // Set lastDir to 'U'
			  	repaint(); // calls a paint event
			}
		}
       	}
	break;

    	case Qt::Key_Down: // Down arrow was pressed
        {
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
	 	else if(!introPrompt1 && !introPrompt2)
		{
			if(paused)
				{pauseGame();} // unpause game

			if(lastDir != 'D' && gameStarted)
			{
				snake->goDown(wrapAround); // Move snake down one block
				checkCollision(); // Check if snake collided with anything
				changedDir = TRUE; // Set changedDir  to true
				lastDir = 'D'; // Set lastDir to 'D'
				repaint(); // calls a paint event
			}
		}
        }
        break;

   	case Qt::Key_P: // 'P' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
		else
		{
	          	pauseGame(); // pause/unpause game
		}
        }
        break;

    	case Qt::Key_R: // 'R' was pressed
        { 

		if(introPrompt2) //If intro prompt 2 screen is displayed, go back to intro screen 1
		{
			//sets up variables for intro prompt 1
			introPrompt1 =TRUE;
			introPrompt2 =FALSE;

			repaint();  // calls a paint event
		}
		else if(!introPrompt1)
		{  
			if(bSOD)
			{
				bSOD = FALSE; // set up variable to disable blue screen of death	
				stopGame(); // set up variables to end game and dispaly game over screen
			}
		
			/* Reloving UnPause/Resume/Restart ISSUES */
			if(paused)
			{
				pauseGame(); //unpause game
			}
		
			stopGame(); // set up variables to end game and dispaly game over screen
			
			//sets up variables for intro prompt 1
			introPrompt1 =TRUE;
			gameOver = FALSE;
			gameWon = FALSE;
			gameEnded = FALSE;

			repaint(); // calls a paint event
		}
        }
        break;
	
	// Move the apple
    	case Qt::Key_M: // 'M' was pressed
    	case Qt::Key_A: // 'A' was pressed
	{ 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
		/* Reloving Paused ISSUES */
		else if(paused)
		{
			// do nothing
		}
		else if(gameStarted) //If game has started move the apple and switch food images 
		{
			// Sets up variable to switch food images
			switchFood++;// increments Apple logo switcher
	    		switchFood %= 2; // if Apple logo switch equals 2, set it back to zero

			// Move the apple and making sure the apple is not on top oof any other object
			do{
				if(winSpawn)
					food->moveFood(foodWinner,switchFood);
				else if(deathSpawn)
					food->moveFood(specialFood,switchFood);
				else
		  			food->moveFood(switchFood);

			}while(snake->checkBadFood(food));
		}
        }
        break;

	// Grow the snake, but don't increase points
    	case Qt::Key_G: // 'G' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
		/* Reloving Paused ISSUES */
		else if(paused)
		{
			// do nothing
		}
		else if(gameStarted && lastDir != ' ')
		{
 			// grow snake, but don't increase points
			snake->grow();
			growCount++;
		
			// If needed, Fix the growCount
			if(fixCount == TRUE)
			{
				growCount--;
				fixCount = FALSE;
			}
		}
        }
        break;

	// set up variable to paint specialFood and move specialFood (the Windows 8 logo)
    	case Qt::Key_W: // 'W' was pressed
	{ 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
		/* Reloving Paused ISSUES */
		else if(paused)
		{
			// do nothing	
		}
		else if(gameStarted)
		{
			
			// set up variable to paint specialFood
			deathSpawn = TRUE;
			doOneTime = FALSE;
			
			// move specialFood making sure it is not on top oof any other object
			do{
				specialFood->moveFood(food);		  	

			}while(snake->checkBadFood(specialFood));

		}
        }
        break;

	// set up variables to dispaly blue screen of death
   	case Qt::Key_8: // '8' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
		/* Reloving Paused ISSUES */
		else if(paused)
		{
			// do nothing
		}
		else if(gameStarted)
		{
			blueScreenDeath(); // set up variables to dispaly blue screen of death
		}
        }
        break;

	// set up variable to paint foodWinner (the Linux logo)
    	case Qt::Key_L: // 'L' was pressed
	{ 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
		/* Reloving Paused ISSUES */
		else if(paused)
		{
			// do nothing
		}
		else if(gameStarted)
		{
			// set up variable to paint foodWinner (the Linux logo)
			spawnWinnerCount = 1000;
			doOneTime = TRUE;
		}
        }
        break;

	// set up variables to dispaly victory screen
    	case Qt::Key_V: // 'V' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
		/* Reloving Paused ISSUES */
		else if(paused)
		{
			// do nothing
		}
		else if(gameStarted)
		{
			victory(); // set up variables to dispaly victory screen
		}
        }
        break;

	// During intro screen 2, this enables wrapAround and starts the game
    	case Qt::Key_Y: // 'Y' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}

		if(introPrompt2)
		{
			wrapAround = TRUE; // enables wrapAround

			// starts the game
			introPrompt2 = FALSE;
			startGame();
		}
        }
        break;

	// During intro screen 2, this disables wrapAround, doubles the points multiplier, and starts the game
    	case Qt::Key_N: // 'N' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}

		if(introPrompt2)
		{
			wrapAround = FALSE;// disables wrapAround

			// starts the game
			introPrompt2 = FALSE;
			pointMulti = pointMulti*2; // doubles the points multiplier
			startGame();
			
		}
        }
        break;

	// During intro screen 1, this sets up speed delay and points multiplier, 
	// and then it will set up the variable for  intro screen 2
    	case Qt::Key_1: // '1' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}

		if(introPrompt1)
		{
			// disables intro screen 1
			introPrompt1 = FALSE;

			// sets up speed delay and points multiplier
			pointMulti = 1;
			speedDelay = 200;
			
			// set up the variable for  intro screen 2
			introPrompt2 = TRUE;
			repaint(); // calls a paint event
		}
        }
        break;

	// During intro screen 1, this sets up speed delay and points multiplier, 
	// and then it will set up the variable for  intro screen 2
    	case Qt::Key_2: // '2' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}

		if(introPrompt1)
		{
			// disables intro screen 1
			introPrompt1 = FALSE;

			// sets up speed delay and points multiplier
			pointMulti = 2;
			speedDelay = 169;

			// set up the variable for  intro screen 2
			introPrompt2 = TRUE;
			repaint(); // calls a paint event
		}
        }
        break;

	// During intro screen 1, this sets up speed delay and points multiplier, 
	// and then it will set up the variable for  intro screen 2
    	case Qt::Key_3: // '3' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}

		if(introPrompt1)
		{
			// disables intro screen 1
			introPrompt1 = FALSE;

			// sets up speed delay and points multiplier
			pointMulti = 3;
			speedDelay = 138;

			// set up the variable for  intro screen 2
			introPrompt2 = TRUE;
			repaint(); // calls a paint event
		}
        }
        break;

	// During intro screen 1, this sets up speed delay and points multiplier, 
	// and then it will set up the variable for  intro screen 2
    	case Qt::Key_4: // '4' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}

		if(introPrompt1)
		{
			// disables intro screen 1
			introPrompt1 = FALSE;

			// sets up speed delay and points multiplier
			pointMulti = 4;
			speedDelay = 107;

			// set up the variable for  intro screen 2
			introPrompt2 = TRUE;
			repaint(); // calls a paint event
		}
        }
        break;

	// During intro screen 1, this sets up speed delay and points multiplier, 
	// and then it will set up the variable for  intro screen 2
    	case Qt::Key_5: // '5' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}

		if(introPrompt1)
		{
			// disables intro screen 1
			introPrompt1 = FALSE;

			// sets up speed delay and points multiplier
			pointMulti = 5;
			speedDelay = 75;

			// set up the variable for  intro screen 2
			introPrompt2 = TRUE;
			repaint(); // calls a paint event
		}
        }
        break;

	// During intro screen 1, this sets up speed delay and points multiplier, 
	// and then it will set up the variable for  intro screen 2
    	case Qt::Key_9: // '9' was pressed
        { 
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}

		if(introPrompt1)
		{
			// disables intro screen 1
			introPrompt1 = FALSE;

			// sets up speed delay and points multiplier
			pointMulti = 1000;
			speedDelay = 0;

			// set up the variable for  intro screen 2
			introPrompt2 = TRUE;
			repaint(); // calls a paint event
		}
        }
        break;

	// If Victory or Game Over screen, sets up the variables for intro screen 1.
	// If BSOD, then sets up variables to end game and dispaly game over screen.
    	case Qt::Key_Space: // The Space Bar was pressed
        {
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame(); // set up variables to end game and dispaly game over screen
		}
		else if(!introPrompt1 && !introPrompt2 && gameEnded)
		{
			// sets up the variables for  intro screen 1
			introPrompt1 =TRUE;
			gameOver = FALSE;
			gameWon = FALSE;
			gameEnded = FALSE;
			repaint(); // calls a paint event
		}

        }
        break;

	// Exits App
    	case Qt::Key_Escape: // The Esc key was pressed
        {
          	qApp->exit();
        }
        break;

	// During BSOD, sets up variables to end game and dispaly game over screen
    	default: // Any other Key was pressed
	{
		if(bSOD)
		{
			bSOD = FALSE; // set up variable to disable blue screen of death	
			stopGame();  // set up variables to end game and dispaly game over screen
		}
	}

	QWidget::keyPressEvent(event);
    }
}
Ejemplo n.º 14
0
bool Context::launchGame(int niveau){

	bool quit=false;
	SDL_Event e;
	srand(time(NULL));
	int key=0;
	bool haut=false;
	bool bas=false;
	bool droite=false;
	bool gauche=false;

	bool attack=false;

	map->respawn(niveau);

	while(!quit){



		while(SDL_PollEvent(&e) !=0){
			if( e.type == SDL_QUIT )
			{
				quit = true;
			}
			//User presses a key
			else if( e.type == SDL_KEYDOWN )
			{

				//Select surfaces based on key press
				switch( e.key.keysym.sym ) { 
				case SDLK_UP:  {

					haut=true;
					bas=false;
					droite=false;
					gauche=false;

							   }
							   break; 
				case SDLK_DOWN: {

					haut=false;
					bas=true;
					droite=false;
					gauche=false;

								}
								break; 
				case SDLK_LEFT: {

					haut=false;
					bas=false;
					droite=false;
					gauche=true;

								}
								break;
				case SDLK_RIGHT: {

					haut=false;
					bas=false;
					droite=true;
					gauche=false;

								 }
								 break; 

				default: 
					break;
				} 
				if(e.key.keysym.sym ==SDLK_SPACE){
					attack = true;
					
					
				}
			}




		}
		if(attack){
			
			map->activateHeroAttack(); 

		}

		if(droite)key=2;
		else if(gauche)key=4;
		else if (haut)key=1;
		else if(bas)key=3;
		else key=0;

		if(key!=0){
			map->setEntityOrientation(0, key);
			map->setEntitySpeed(0, 4);
		}
		else map->setEntitySpeed(0, 0);
		int tmp=(rand()%20)+1;
		if(tmp==5)
			map->activateAI();


		map->moveEntities();

		for(int i=1; i < map->getTableEntities().size(); i++){
			if(physicEngine->collision(map->getEntityX(0),map->getEntityY(0), map->getEntityX(i), map->getEntityY(i) ) ){
				map->bam(i);
			}
		}

		if(map->heroDead()){
			audioEngine->playGameOverEffect();
			map->respawn(niveau);
			haut=false;
			bas=false;
			droite=false;
			gauche=false;
		}
		graphicEngine->displayBackground(*map, niveau);
		if(graphicEngine->displayEntities(map->getTableEntities(), attack )&& attack==true) audioEngine->playGunEffect();

			attack=false;


		if(victory(map->getEntityX(0), map->getEntityY(0), niveau)){
			audioEngine->playWinEffect();
			return true;
		}

		graphicEngine->refresh();

	}

	 gHelloWorld = SDL_LoadBMP( "picture/end.bmp" ); 
	if( gHelloWorld == NULL ) { 
	printf( "Unable to load image %s! SDL Error: %s\n", "02_getting_an_image_on_the_screen/hello_world.bmp", SDL_GetError() );
	 } 

	 SDL_BlitSurface( gHelloWorld, NULL, gScreenSurface, NULL );
	  SDL_UpdateWindowSurface( window );

	  SDL_Delay(3000);

	return false;
}
Ejemplo n.º 15
0
void manage_physics_lvl1(PLAYER* player)
{

	if(player->box.x == 8U && player->box.y == 136U && (player->state == CROUCHWALK || player->state == CROUCH) && player->dirX == -1 )
	{

		player->newX = 160U-PLAYER_SIZE;
		player->newY = 136U;
		player->booleanState = player->booleanState | TRANSITIONNING;
		player->state = CROUCHTRANSITIONIN;
		player->timer = 0U;
		player->img_index = 0U;

		player->nextLevel = LEVEL2;
		//switch_to_level(LEVEL2);

	}else if(player->box.x >= 104U && player->box.x <= 136U && player->box.y == PLAYER_SIZE+8U && player->state == CLIMBWALK)
	{

		player->box.y = 135U;
		switch_to_level(LEVEL4);
	}else if(player->box.x == 8U && player->box.y == 80U &&
			(player->state == CROUCHWALK || player->state == CROUCH) && player->dirX == -1 )
	{

		player->newX = 160U-PLAYER_SIZE;
		player->newY = 80U;
		player->booleanState = player->booleanState | TRANSITIONNING;
		player->state = CROUCHTRANSITIONIN;
		player->timer = 0U;
		player->img_index = 0U;

		player->nextLevel = LEVEL2;

	}else if(player->box.x == 72U-PLAYER_SIZE && player->box.y == 80U &&
			(player->state == CROUCHWALK || player->state == CROUCH) && player->dirX == 1 )
	{

		player->newX = 72U-2U;
		player->newY = 80U;
		player->booleanState = player->booleanState | TRANSITIONNING;
		player->state = CROUCHTRANSITIONIN;
		player->timer = 0U;
		player->img_index = 0U;

		player->nextLevel = NOLEVEL;
		//switch_to_level(LEVEL2);

	}
	else if(player->box.x == 80U && player->box.y == 80U &&
			(player->state == CROUCHWALK || player->state == CROUCH)&& player->dirX == -1 )
	{

		player->newX = 72U-PLAYER_SIZE+8U;
		player->newY = 80U;
		player->booleanState = player->booleanState | TRANSITIONNING;
		player->state = CROUCHTRANSITIONIN;
		player->timer = 0U;
		player->img_index = 0U;

		player->nextLevel = NOLEVEL;
		//switch_to_level(LEVEL2);

	}
	if(player->key != NULL && checkCollision(&(player->key->box), locks_lvl1[0].box))
	{
		player->key->box.x = player->key->originX;
		player->key->box.y = player->key->originY;
		player->key->used = 1U;
		player->key = NULL;
		locks_lvl1[0].box->x = 0U;
		locks_lvl1[0].box->y = 0U;
		locks_lvl1[0].box->w = 0U;
		locks_lvl1[0].box->h = 0U;
		locks_lvl1[0].locked = 0U;
		victory();
		SWITCH_ROM_MBC1(6);

	}
	/*if(checkCollision(&(enemy_lvl1[0].box), &(player->box)))
	{
		manage_enemy_collision(player, (ENEMY*) enemy_lvl1);
	}*/

}
Ejemplo n.º 16
0
//checks positions of objects and if they collide
void Zomgame::checkCollision()
{

//swapping from top-bottom, left-right vice versa
if(level2 != TRUE){

int top=  player->getRect().top();
int left= player->getRect().left();

if (player->rect.left() <= 0) {	//if hit left edge, move right
    player->rect.moveTo(1185,top);
  }

  if (player->rect.left() >= 1200){ //if hit right edge, move left
   player->rect.moveTo(15,top);
  }

  if (player->rect.top() <= 0) { //if hit top edge, move down
  player->rect.moveTo(left,985);
  }
  
  if (player->rect.top() >= 1000) { //if hit bottom edge, move up
   player->rect.moveTo(left,10);
}

}

//no swapping in level 2, played a bit like frogger
if(level2==TRUE){
int top=  player->getRect().top();
int left= player->getRect().left();
if (player->rect.left() <= 0) {	//if hit left edge, move right
    player->rect.moveTo(30,top);
  }

  if (player->rect.left() >= 1200){ //if hit right edge, move left
   player->rect.moveTo(1170,top);
  }

  if (player->rect.top() <= 0) { //if hit top edge, move down
  player->rect.moveTo(left,30);
  }
  
  if (player->rect.top() >= 1000) { //if hit bottom edge, move up
   player->rect.moveTo(left,970);
}

}


 if(level1==TRUE){

//following zombie, finds and moves towards player at all times
z4->image.load("follower.png");
z4->autoMove();
if(z4->rect.left() < player->rect.left())   {
z4->xdir=2;}
if(z4->rect.right() > player->rect.right())   {
z4->xdir=-2;}
if(player->rect.bottom() < z4->getRect().bottom()) z4->ydir=-2;
if(player->rect.top() > z4->getRect().top()) z4->ydir=2;



	//player hits  zombies
  if ( (player->getRect()).intersects(zombie->getRect()) ||(player->getRect()).intersects(zombie2->getRect()) || (player->getRect()).intersects(zombie3->getRect()) || (player->getRect()).intersects(z3->getRect()) || (player->getRect()).intersects(z4->getRect())) {

    player->resetState(); //respawn player
    lives--;//subtract life
    score-=50;//subtract score
 
}
	
//player and landmine
if ( (player->getRect()).intersects(landmine->getRect()) || (player->getRect()).intersects(l2->getRect()) || (player->getRect()).intersects(l3->getRect()) || (player->getRect()).intersects(l4->getRect()) || (player->getRect()).intersects(l5->getRect()) ||  (player->getRect()).intersects(l6->getRect())|| (player->getRect()).intersects(l7->getRect()) || (player->getRect()).intersects(l8->getRect()) || (player->getRect()).intersects(l9->getRect()) || (player->getRect()).intersects(l10->getRect())) {
 
    player->resetState();
lives--;
score-=50;
 

}

//player and civilian
if ( (player->getRect()).intersects(civilian->getRect())) {

    civilian->resetState();//respawn civilian
score+=100;//add score

}

 if(score>=500){ level2=TRUE;//if score at 500, level 1 complete, level 2 start, player start at new location
player->rect.moveTo(600,1000);
level1=FALSE;}
}



if(level2==TRUE){		//buttons initialize unpressed image
b->image.load("button.png");
b2->image.load("button.png");
b3->image.load("button.png");
b4->image.load("button.png");




if( (player->getRect()).intersects(s->getRect()) ){		//few life objects add to players lives

s->rect.moveTo(-200,-200);
lives++;
}
if( (player->getRect()).intersects(s2->getRect()) ){

s2->rect.moveTo(-200,-200);
lives++;
}

if( (player->getRect()).intersects(s3->getRect()) ){

s3->rect.moveTo(-200,-200);
lives++;
}


if( (player->getRect()).intersects(b->getRect()) ){	//player hits a button to spawn a new one

b->image.load("button2.png");	//when player is on button, a "pressed" image will load, simulates really touching a button
b2->rect.moveTo(700,900);
}
if( (player->getRect()).intersects(b2->getRect()) ){

b2->image.load("button2.png");
b3->rect.moveTo(500,500);
}
if(ncar->rect.right() > 1200){ncar->rect.moveTo(-1000,725);}

if( (player->getRect()).intersects(b3->getRect()) ){

b3->image.load("button2.png");
b4->rect.moveTo(300,30);
}
if(zcar->rect.left() <= 0){zcar->rect.moveTo(1170,265);}

if( (player->getRect()).intersects(b4->getRect()) ){	

b4->image.load("button2.png");
b5->rect.moveTo(900,900);
b5->image.load("button4.png");
car4->image.load("zomcar2.png");
car4->xdir=5;
}
if(car4->rect.right() >= 1200){car4->rect.moveTo(10,370);}

if( (player->getRect()).intersects(b6->getRect()) ){	//fake button kills player

player->rect.moveTo(600,1000);
lives--;
b6->image.load("button3.png");
}


if( (player->getRect()).intersects(s4->getRect()) ){	//fake life.....also kills player

player->rect.moveTo(600,1000);
lives--;
s4->image.load("fakelife.png");
}

	//player and zombie cars
if( (player->getRect()).intersects(car->getRect()) || (player->getRect()).intersects(car2->getRect()) || (player->getRect()).intersects(car3->getRect()) || (player->getRect()).intersects(car4->getRect()) || (player->getRect()).intersects(ncar->getRect()) || (player->getRect()).intersects(zcar->getRect()) ){

player->rect.moveTo(600,1000);
lives--;
}

//final button moves player to level 3
if( (player->getRect()).intersects(b5->getRect()) ){

level3=TRUE;
player->rect.moveTo(600,600);
level2=FALSE;
}
}




if(level3==TRUE){
  bg2->image.load("space.png");
//shooters
sh1->autoMove();	//shooters start moving when they sense player in level 3
sh2->autoMove();
sh3->autoMove();
sh4->autoMove();

sh1->xdir=0; sh1->ydir=0;	//initially they dont move
sh2->xdir=0; sh2->ydir=0;
sh3->xdir=0; sh3->ydir=0;
sh4->xdir=0; sh4->ydir=0;

	//they move to players row or column
if((player->getRect().left()) <(sh1->getRect().left())) sh1->xdir=-8;
if((player->getRect().right()) >(sh1->getRect().right())) sh1->xdir=8;

if((player->getRect().bottom()) < (sh2->getRect().bottom())) sh2->ydir=-8;
if((player->getRect().top()) > (sh2->getRect().top())) sh2->ydir=8;

if((player->getRect().bottom()) < (sh2->getRect().bottom())) sh2->ydir=-8;
if((player->getRect().top()) > (sh2->getRect().top())) sh2->ydir=8;

if((player->getRect().left()) <(sh3->getRect().left())) sh3->xdir=-8;
if((player->getRect().right()) >(sh3->getRect().right())) sh3->xdir=8;

if((player->getRect().bottom()) < (sh4->getRect().bottom())) sh4->ydir=-8;
if((player->getRect().top()) > (sh4->getRect().top())) sh4->ydir=8;

int S1B= sh1->getRect().bottom();	//bullets find shooters respective positios
int S1L= sh1->getRect().left();
int S2R= sh2->getRect().right();
int S2T= sh2->getRect().top();
int S3T= sh3->getRect().top();
int S3L= sh3->getRect().left();
int S4L= sh4->getRect().left();
int S4B= sh4->getRect().bottom();


if( (bullet1->getRect().top()) >1000)
{
  score+=300; //dodging bullets gives score
bullet1->rect.moveTo(S1L+20,S1B-100);	//bullets respawn to whereever shooters have moved once off screen
shots--;
}
if( (bullet2->getRect().left()) >1200)
{ 
  score+=300;
bullet2->rect.moveTo(S2R-100,S2T+20);
shots--;
}
if( (bullet3->getRect().bottom()) <0)
{
  score+=300;
bullet3->rect.moveTo(S3L+20,S3T);
shots--;
}
if( (bullet4->getRect().right()) <0)
{
  score+=300;
bullet4->rect.moveTo(S4L,S4B-100);
shots--;								//when bullets hit screen, if player is still alive, counted as dodged
}

if( (player->getRect()).intersects(sh1->getRect()) || (player->getRect()).intersects(sh2->getRect()) || (player->getRect()).intersects(sh3->getRect()) || (player->getRect()).intersects(sh4->getRect()) || (player->getRect()).intersects(bullet1->getRect()) || (player->getRect()).intersects(bullet2->getRect()) || (player->getRect()).intersects(bullet3->getRect()) || (player->getRect()).intersects(bullet4->getRect()) ){

player->rect.moveTo(50,50);
lives--;
}


if(shots<=0){	//players move to final level when they dodge 30 shots

level4=TRUE;

player->rect.moveTo(1100,950);
level3=FALSE;

}
}


if(level4==TRUE){

if( (player->getRect()).intersects(boss->getRect()) || (player->getRect()).intersects(axe->getRect()) ){

player->rect.moveTo(1000,950);
lives--;
}

if( (pshot->getRect()).intersects(boss->getRect()) ){

bosslife=bosslife-10;	//pshot damage per shot
score+=10;
}

//player's shot attack is automatic and does damage to the boss
int PL= player->getRect().left();
int PT= player->getRect().bottom();


if( (pshot->getRect().bottom()) < 0)
{ 
pshot->rect.moveTo(PL,PT);
}

if( (pshot->getRect()).intersects(boss->getRect()))
{ 
pshot->rect.moveTo(PL,PT);
}

//Boss and Weapon


//left side attack
//boss "throws" weapon and retrieves it


if((boss->getRect().left()<=115)){
boss->image.load("ganonu.png");
}
if((boss->getRect().left()<=110)){
boss->image.load("boss.png");
axe->rect.moveTo(-200,-200);
}
if((boss->getRect().left()<=100)){
boss->image.load("axethrow.png");
axe->rect.moveTo(100,500);
}
if((boss->getRect().left()<=95)){
boss->image.load("axethrow2.png");
axe->rect.moveTo(100,510);
}
if((boss->getRect().left()<=90)){
axe->rect.moveTo(100,525);
}
if((boss->getRect().left()<=85)){
axe->rect.moveTo(100,540);
axe->image.load("axe2.png");  
}
if((boss->getRect().left()<=80)){
axe->rect.moveTo(100,555);
}
if((boss->getRect().left()<=75)){
axe->rect.moveTo(100,570);
}
if((boss->getRect().left()<=70)){
axe->rect.moveTo(100,585);
axe->image.load("axe3.png");  
}
if((boss->getRect().left()<=65)){
axe->rect.moveTo(100,600);
}
if((boss->getRect().left()<=60)){
axe->rect.moveTo(100,615);
}
if((boss->getRect().left()<=55)){
axe->rect.moveTo(100,630);
axe->image.load("axe4.png");  
}
if((boss->getRect().left()<=50)){
axe->rect.moveTo(100,645);
}
if((boss->getRect().left()<=45)){
axe->rect.moveTo(100,660);
}
if((boss->getRect().left()<=40)){
axe->rect.moveTo(100,675);
axe->image.load("axe5.png");  
}
if((boss->getRect().left()<=35)){
axe->rect.moveTo(100,690);
}
if((boss->getRect().left()<=30)){
axe->rect.moveTo(100,705);
}
if((boss->getRect().left()<=25)){
axe->rect.moveTo(100,720);
axe->image.load("axe6.png");  
}
if((boss->getRect().left()<=20)){
axe->rect.moveTo(100,735);
}
if((boss->getRect().left()<=15)){
axe->rect.moveTo(100,750);
}
if((boss->getRect().left()<=10)){
axe->rect.moveTo(100,765);
axe->image.load("axe7.png");  
}
if((boss->getRect().left()<=5)){
axe->rect.moveTo(100,780);
}


//right side attack
	//same as left side

if((boss->getRect().right()>=1090)){
axe->rect.moveTo(-200,-200);
boss->image.load("ganonu.png");
}
if((boss->getRect().right()>=1095)){
boss->image.load("boss.png");
}
if((boss->getRect().right()>=1100)){
boss->image.load("axethrow.png");
axe->rect.moveTo(800,500);
}
if((boss->getRect().right()>=1105)){
boss->image.load("axethrow2.png");
axe->rect.moveTo(800,510);
}
if((boss->getRect().right()>=1110)){
axe->rect.moveTo(800,525);
}
if((boss->getRect().right()>=1115)){
axe->rect.moveTo(800,540);
axe->image.load("axe2.png");  
}
if((boss->getRect().right()>=1120)){
axe->rect.moveTo(800,555);
}
if((boss->getRect().right()>=1125)){
axe->rect.moveTo(800,570);
}
if((boss->getRect().right()>=1130)){
axe->rect.moveTo(800,585);
axe->image.load("axe3.png");  
}
if((boss->getRect().right()>=1135)){
axe->rect.moveTo(800,600);
}
if((boss->getRect().right()>=1140)){
axe->rect.moveTo(800,615);
}
if((boss->getRect().right()>=1145)){
axe->rect.moveTo(800,630);
axe->image.load("axe4.png");  
}
if((boss->getRect().right()>=1150)){
axe->rect.moveTo(800,645);
}
if((boss->getRect().right()>=1155)){
axe->rect.moveTo(800,660);
}
if((boss->getRect().right()>=1160)){
axe->rect.moveTo(800,675);
axe->image.load("axe5.png");  
}
if((boss->getRect().right()>=1165)){
axe->rect.moveTo(800,690);
}
if((boss->getRect().right()>=1170)){
axe->rect.moveTo(800,705);
}
if((boss->getRect().right()>=1175)){
axe->rect.moveTo(800,720);
axe->image.load("axe6.png");  
}
if((boss->getRect().right()>=1180)){
axe->rect.moveTo(800,735);
}
if((boss->getRect().right()>=1185)){
axe->rect.moveTo(800,750);
}
if((boss->getRect().right()>=1190)){
axe->rect.moveTo(800,765);
axe->image.load("axe7.png");  
}
if((boss->getRect().right()>=1195)){
axe->rect.moveTo(800,780);
}

if(bosslife==0){ victory();} //when player "kills" boss, the game is won and can be played from level 1 again or exited.
}






if(lives<=0) stopGame();//if all lives lost, game over

}
Ejemplo n.º 17
0
int main(int argc, char *argv[]) {
	Game *game = create_game(ROWS, COLS);
	if (argc==3 && !strcmp(argv[1], "display")) {
		char *p = argv[2];
		char *err;
		while (*p) {
			int col = *p - '0';
			if (col>=0 && col<COLS) {
				if (can_play(game, col)) {
					play(game, col);
					if (victory(game, col))
						printf("victory!\n");
				}
				else {
					err = "illegal move";
					goto err_handler;
				}
			}
			else {
				int i;
				err = "unknown move syntax";
err_handler:
				fprintf(stderr, "error: %s.\n%s\n", err, argv[2]);
				for (i=0; i<p-argv[2]; i++)
					fprintf(stderr, " ");
				fprintf(stderr, "^\n");
				return 2;
			}
			p++;
		}
		print_board(game);
	}
	else if ((argc==2 || argc==3) && !strcmp(argv[1], "play")) {
		int j;
		if (argc==3 && !strcmp(argv[2], "red"))
			goto red;
		while (1) {
			print_board(game);
			do {
				printf("Your move: ");
				if (scanf("%d", &j) != 1) {
					printf("\n");
					goto out;
				}
			} while (!can_play(game, j));
			play(game, j);
			if (victory(game, j)) {
				printf("You've won!\n");
				break;
			}
			else {
				int ret = negamax(game, DEFEAT, VICTORY, 12, &j);
red:
				if (ret == CUT)
					printf("I've got no idea what to do...\n"
						"I'm gonna try %d.\n", j);
				else
					printf("I'll play %d (score %d)\n", j, ret);
				play(game, j);
				if (victory(game, j)) {
					printf("You've lost!\n");
					break;
				}
			}
		}
		print_board(game);
	}
	else {
		fprintf(stderr, "usage:\t%s display moves\n", argv[0]);
		fprintf(stderr, "\t%s play [yellow|red]\n", argv[0]);
		fprintf(stderr, "try:\t%s display 01221\n", argv[0]);
		fprintf(stderr, "\t%s play\n", argv[0]);
		return 1;
	}
out:
	destroy_game(game);
	return 0;
}