Пример #1
0
//called when the player has finished a level
PlayerFinishedLevel(int secret_flag)
{
	int	rval;
	int 	was_multi = 0;

	//credit the player for hostages
	Players[Player_num].hostages_rescued_total += Players[Player_num].hostages_on_board;

	if (!(Game_mode & GM_MULTI) && (secret_flag)) {
		newmenu_item	m[1];

		m[0].type = NM_TYPE_TEXT;
		m[0].text = " ";			//TXT_SECRET_EXIT;

		newmenu_do2(NULL, TXT_SECRET_EXIT, 1, m, NULL, 0, "MENU.PCX");
	}

// -- mk mk mk -- used to be here -- mk mk mk --

	if (Game_mode & GM_NETWORK)
		if (secret_flag)
			Players[Player_num].connected = 4; // Finished and went to secret level
		else
			Players[Player_num].connected = 2; // Finished but did not die

	last_drawn_cockpit = -1;

	if (Current_level_num == Last_level) {
		#ifdef NETWORK
		if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))
		{
			was_multi = 1;
			multi_endlevel_score();
			rval = AdvanceLevel(secret_flag);				//now go on to the next one (if one)
		}
		else 
		#endif
		{	// Note link to above else!
			rval = AdvanceLevel(secret_flag);				//now go on to the next one (if one)
			DoEndLevelScoreGlitz(0);		//give bonuses
		}
	} else {
		#ifdef NETWORK
		if (Game_mode & GM_MULTI)
			multi_endlevel_score();
		else 
		#endif	// Note link!!
			DoEndLevelScoreGlitz(0);		//give bonuses
		rval = AdvanceLevel(secret_flag);				//now go on to the next one (if one)
	}

	if (!was_multi && rval) {
		if (Current_mission_num == 0)
			scores_maybe_add_player(0);
		longjmp( LeaveGame, 0 );		// Exit out of game loop
	}
	else if (rval)
		longjmp( LeaveGame, 0 );
}
Пример #2
0
void UpdateRockets(struct Game *game, struct RocketsResources *data, struct Rocket* rockets) {
	  struct Rocket *tmp = rockets;
		while (tmp) {
			  tmp->dy+= tmp->modifier;
				if (!tmp->blown) {
					  tmp->dx+= (tmp->dx > 0) ? (-tmp->modifier / 5 + 0.001) : (tmp->modifier / 5 - 0.001);
				}
				MoveCharacter(game, tmp->character, tmp->dx, tmp->dy, tmp->blown ? 0 : ((tmp->dx > 0) ? 0.0166 : -0.0166));
				AnimateCharacter(game, tmp->character, 1);

				if (!tmp->blown) {

					  if (((((GetCharacterY(game, tmp->character) > 90) && (rand() % 4 == 0) && (tmp->dy > 0)))) && (GetCharacterX(game, tmp->character) > -20 && GetCharacterX(game, tmp->character) < 320)) {
							  tmp->blown = true;
								tmp->modifier = 0;
								tmp->character->angle = 0;
								tmp->dx = 0;
								tmp->dy = 0;
								SelectSpritesheet(game, tmp->character, "boom");
								MoveCharacter(game, tmp->character, 5, 5, 0);

								if (!((GetCharacterX(game, tmp->character) > 140) && (GetCharacterX(game, tmp->character) < 180))) {
									  if (!data->lost) {
											  AdvanceLevel(game, false);

												data->lost = true;
												data->flash = 4;
										data->counter = 0;
										TM_AddDelay(data->timeline, 3500);
										if (game->data->mediator.lives > 0) {
											  TM_AddAction(data->timeline, switchMinigame, NULL, "switchMinigame");
										} else {
											  TM_AddAction(data->timeline, theEnd, NULL, "theEnd");
										}
										data->spawnspeed = 10;

										al_play_sample_instance(data->riot_sound);

										}
										al_play_sample_instance(data->boom_sound);

								}

						} else if (GetCharacterX(game, tmp->character) < -20 || GetCharacterX(game, tmp->character) > 320) {
							  tmp->blown = true;
								tmp->modifier = 0;
								tmp->character->angle = 0;
								tmp->dx = 0;
								tmp->dy = 0;
								SelectSpritesheet(game, tmp->character, "blank");
								al_play_sample_instance(data->boom_sound);
						}
				}
				tmp=tmp->next;
		}
}
Пример #3
0
//called when the player has died
void DoPlayerDead()
{
	int cycle_window_vis = 1;
#ifdef NETWORK
	if ( (Game_mode & GM_MULTI) && (Netgame.SpawnStyle == SPAWN_STYLE_PREVIEW))  {
		cycle_window_vis = 0; 
	}
#endif

	if (Game_wind && cycle_window_vis)
		window_set_visible(Game_wind, 0);

	reset_palette_add();

	gr_palette_load (gr_palette);

	dead_player_end();		//terminate death sequence (if playing)

	#ifdef EDITOR
	if (Game_mode == GM_EDITOR) {			//test mine, not real level
		object * player = &Objects[Players[Player_num].objnum];
		//nm_messagebox( "You're Dead!", 1, "Continue", "Not a real game, though." );
		if (Game_wind)
			window_set_visible(Game_wind, 1);
		load_level("gamesave.lvl");
		init_player_stats_new_ship(Player_num);
		player->flags &= ~OF_SHOULD_BE_DEAD;
		StartLevel(0);
		return;
	}
	#endif

#ifdef NETWORK
	if ( Game_mode&GM_MULTI )
	{
		multi_do_death(Players[Player_num].objnum);
	}
	else
#endif
	{				//Note link to above else!
		Players[Player_num].lives--;
		if (Players[Player_num].lives == 0)
		{
			DoGameOver();
			return;
		}
	}

	if ( Control_center_destroyed ) {
		int	rval;

		//clear out stuff so no bonus
		Players[Player_num].hostages_on_board = 0;
		Players[Player_num].energy = 0;
		Players[Player_num].shields = 0;
#ifdef NETWORK
		Players[Player_num].connected = CONNECT_DIED_IN_MINE;
#endif

		do_screen_message(TXT_DIED_IN_MINE); // Give them some indication of what happened

		if (Current_level_num == Last_level) {
#ifdef NETWORK
			if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))
			{
				multi_endlevel_score();
				rval = AdvanceLevel(0);			//if finished, go on to next level
			}
			else
#endif
			{			// Note link to above else!
				rval = AdvanceLevel(0);			//if finished, go on to next level
				DoEndLevelScoreGlitz(0);
			}
			init_player_stats_new_ship(Player_num);
			last_drawn_cockpit = -1;
		} else {
#ifdef NETWORK
			if (Game_mode & GM_MULTI)
				multi_endlevel_score();
			else
#endif
				DoEndLevelScoreGlitz(0);		// Note above link!

			rval = AdvanceLevel(0);			//if finished, go on to next level
			init_player_stats_new_ship(Player_num);
			last_drawn_cockpit = -1;
		}

		if (rval) {
#ifndef SHAREWARE
			if (PLAYING_BUILTIN_MISSION)
#endif
				scores_maybe_add_player(0);
			if (Game_wind)
				window_close(Game_wind);		// Exit out of game loop
		}
	} else {
		init_player_stats_new_ship(Player_num);
		StartLevel(1);
	}

	if (Game_wind  && cycle_window_vis)
		window_set_visible(Game_wind, 1);
	reset_time();
}
Пример #4
0
//called when the player has finished a level
void PlayerFinishedLevel(int secret_flag)
{
	int	rval;
	int 	was_multi = 0;

	if (Game_wind)
		window_set_visible(Game_wind, 0);

	//credit the player for hostages
	Players[Player_num].hostages_rescued_total += Players[Player_num].hostages_on_board;

#ifndef SHAREWARE
	if (!(Game_mode & GM_MULTI) && (secret_flag)) {
		newmenu_item	m[1];

		m[0].type = NM_TYPE_TEXT;
		m[0].text = " ";			//TXT_SECRET_EXIT;

		newmenu_do2(NULL, TXT_SECRET_EXIT, 1, m, NULL, NULL, 0, Menu_pcx_name);
	}
#endif

// -- mk mk mk -- used to be here -- mk mk mk --

#ifdef NETWORK
	if (Game_mode & GM_NETWORK)
         {
		if (secret_flag)
			Players[Player_num].connected = CONNECT_FOUND_SECRET; // Finished and went to secret level
		else
			Players[Player_num].connected = CONNECT_WAITING; // Finished but did not die
         }
#endif
	last_drawn_cockpit = -1;

	if (Current_level_num == Last_level) {
#ifdef NETWORK
		if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))
		{
			was_multi = 1;
			multi_endlevel_score();
			rval = AdvanceLevel(secret_flag);				//now go on to the next one (if one)
		}
		else
#endif
		{	// Note link to above else!
			rval = AdvanceLevel(secret_flag);				//now go on to the next one (if one)
			DoEndLevelScoreGlitz(0);		//give bonuses
		}
	} else {
#ifdef NETWORK
		if (Game_mode & GM_MULTI)
			multi_endlevel_score();
		else
#endif	// Note link!!
			DoEndLevelScoreGlitz(0);		//give bonuses
		rval = AdvanceLevel(secret_flag);				//now go on to the next one (if one)
	}

	if (!was_multi && rval) {
#ifndef SHAREWARE
		if (PLAYING_BUILTIN_MISSION)
#endif
			scores_maybe_add_player(0);
		if (Game_wind)
			window_close(Game_wind);		// Exit out of game loop
	}
	else if (rval && Game_wind)
		window_close(Game_wind);

	if (Game_wind)
		window_set_visible(Game_wind, 1);
	reset_time();
}
Пример #5
0
//called when the player has died
void DoPlayerDead()
{
	reset_palette_add();

	gr_palette_load (gr_palette);

	dead_player_end();		//terminate death sequence (if playing)

#ifdef HOSTAGE_FACES
	stop_all_hostage_clips();
#endif

	#ifdef EDITOR
	if (Game_mode == GM_EDITOR) {			//test mine, not real level
		object * player = &Objects[Players[Player_num].objnum];
		//nm_messagebox( "You're Dead!", 1, "Continue", "Not a real game, though." );
		load_level("gamesave.lvl");
		init_player_stats_new_ship();
		player->flags &= ~OF_SHOULD_BE_DEAD;
		StartLevel(0);
		return;
	}
	#endif

	#ifdef NETWORK
	if ( Game_mode&GM_MULTI )
	{
		multi_do_death(Players[Player_num].objnum);
	}
	else 
	#endif		
	{				//Note link to above else!
		Players[Player_num].lives--;
		if (Players[Player_num].lives == 0)
		{	
			DoGameOver();
			return;
		}
	}
				
	if ( Fuelcen_control_center_destroyed ) {
		int	rval;

		//clear out stuff so no bonus
		Players[Player_num].hostages_on_board = 0;
		Players[Player_num].energy = 0;
		Players[Player_num].shields = 0;
		Players[Player_num].connected = 3;

		died_in_mine_message(); // Give them some indication of what happened

		if (Current_level_num == Last_level) {
			#ifdef NETWORK
			if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))
			{
				multi_endlevel_score();
				rval = AdvanceLevel(0);			//if finished, go on to next level
			}
			else
			#endif	
			{			// Note link to above else!
				rval = AdvanceLevel(0);			//if finished, go on to next level
				DoEndLevelScoreGlitz(0);	
			}
			init_player_stats_new_ship();
			last_drawn_cockpit = -1;
		} else {
			#ifdef NETWORK
			if (Game_mode & GM_MULTI)
				multi_endlevel_score();
			else
			#endif
				DoEndLevelScoreGlitz(0);		// Note above link!

			rval = AdvanceLevel(0);			//if finished, go on to next level
			init_player_stats_new_ship();
			last_drawn_cockpit = -1;
		}

		if (rval) {
#ifndef SHAREWARE
			if (PLAYING_BUILTIN_MISSION)
#endif
				scores_maybe_add_player(0);
			longjmp( LeaveGame, 1 );		// Exit out of game loop
		}
	} else {
		init_player_stats_new_ship();
		StartLevel(1);
	}

}
Пример #6
0
void Gamestate_Logic(struct Game *game, struct RocketsResources* data) {

	  if ((data->spawncounter == data->currentspawn) && ((data->counter < data->timelimit) || (data->lost))) {
			  if (rand() % 2 == 0) {
					  data->rockets_left = CreateRocket(game, data, data->rockets_left, false);
				} else {
					  data->rockets_right = CreateRocket(game, data, data->rockets_right, true);
				}
				data->spawncounter = 0;
		}

		if (!data->flash) {
			  UpdateRockets(game, data, data->rockets_left);
				UpdateRockets(game, data, data->rockets_right);
		} else {
			  data->flash--;
		}

		if (data->lost) {
			  data->zadyma++;
				if (data->zadyma >= 255) {
					  data->zadyma = 255;
				}
		}

		AnimateCharacter(game, data->usa_flag, 1);
		AnimateCharacter(game, data->ru_flag, 1);
		AnimateCharacter(game, data->riot, 1);
		if ((data->lost) && (data->hearts > 80)) {
			  AnimateCharacter(game, game->data->mediator.heart, 1);
				if (game->data->mediator.heart->pos == 6) {
					  al_play_sample_instance(data->boom_sound);
				}
		}

		if (data->lost) {
			  data->hearts++;
		}

		if (data->won) {
			  AnimateCharacter(game, data->euro, 1);
		}

		if ((data->counter >= data->timelimit) && (!data->lost) && (!data->won)) {
			  bool stillthere = false;
				struct Rocket *tmp = data->rockets_left;
				while (tmp) {
					  if (!tmp->blown) {
							  stillthere = true;
								break;
						}
						tmp = tmp->next;
				}
				tmp = data->rockets_right;
				while (tmp) {
					  if (!tmp->blown) {
							  stillthere = true;
								break;
						}
						tmp = tmp->next;
				}
				if (!stillthere) {
					  SelectSpritesheet(game, data->euro, "euro");
						SetCharacterPosition(game, data->euro, 0, 0, 0);
						al_play_sample_instance(data->wuwu_sound);
						data->won = true;
						AdvanceLevel(game, true);
						SelectSpritesheet(game, data->usa_flag, "poland");
						SelectSpritesheet(game, data->ru_flag, "poland");
						TM_AddDelay(data->timeline, 2500);
						TM_AddAction(data->timeline, switchMinigame, NULL, "switchMinigame");
				}
		}


		void iterate(struct Rocket *start) {
			  struct Rocket *tmp1 = start;
				while (tmp1) {
					  if (!tmp1->blown) {
							//  if (CheckCollision(game, data, data->cursor, tmp1->character)) {

							  if ( (abs(GetCharacterY(game, tmp1->character) - GetCharacterY(game, data->cursor)) <= 10) &&
								     (((GetCharacterX(game, tmp1->character) <= GetCharacterX(game, data->cursor) + al_get_bitmap_width(data->cursor->bitmap)) && (GetCharacterX(game, tmp1->character) + al_get_bitmap_width(tmp1->character->bitmap) >= GetCharacterX(game, data->cursor) + al_get_bitmap_width(data->cursor->bitmap)))  ||

								     ((GetCharacterX(game, tmp1->character) + al_get_bitmap_width(tmp1->character->bitmap) >= GetCharacterX(game, data->cursor)) && (GetCharacterX(game, tmp1->character) + al_get_bitmap_width(tmp1->character->bitmap) <= GetCharacterX(game, data->cursor) + al_get_bitmap_width(data->cursor->bitmap))) )) {

									  if (GetCharacterY(game, tmp1->character) < GetCharacterY(game, data->cursor)) {
											  tmp1->dx = 0;
												tmp1->dy = 0;
												tmp1->modifier = 0;
												tmp1->blown = true;
												SelectSpritesheet(game, tmp1->character, "blank");
										} else if (tmp1->dy < 0) {
											  tmp1->dy *= -1;
										}

										al_play_sample_instance(data->rocket_sound);

								}

						}
						tmp1 = tmp1->next;
				}

		}
		iterate(data->rockets_left);
		iterate(data->rockets_right);

		data->counter++;
		data->spawncounter++;
		data->cloud_rotation += 0.002;

		TM_Process(data->timeline);
}