Esempio n. 1
0
File: player.c Progetto: deurk/ktx
void player_light2()
{
	self->s.v.frame = 106;
	self->think = ( func_t ) player_light1;
	self->s.v.nextthink = g_globalvars.time + 0.1;

	if ( !self->s.v.button0 || intermission_running || self->s.v.impulse )
	{
		if (lgc_enabled()) {
			lgc_register_fire_stop(self);
		}
		self->walkframe = 0;
		player_run();
		return;
	}

	set_idealtime();
	muzzleflash();

	self->s.v.weaponframe = self->s.v.weaponframe + 1;
	if ( self->s.v.weaponframe >= 5 )
		self->s.v.weaponframe = 1;

	SuperDamageSound();
	W_FireLightning();
	self->attack_finished = g_globalvars.time + 0.2;
}
Esempio n. 2
0
void object_dynamic_tick(object *obj) {
    obj->age++;

    if(obj->attached_to != NULL) {
        object_set_pos(obj, object_get_pos(obj->attached_to));
        object_set_direction(obj, object_get_direction(obj->attached_to));
    }

    // Check if object still needs to be halted
    if(obj->halt_ticks > 0) {
        obj->halt_ticks--;
        obj->halt = (obj->halt_ticks > 0);
    }

    // Run animation player
    if(obj->cur_animation != NULL && obj->halt == 0) {
        for(int i = 0; i < obj->stride; i++)
            player_run(obj);
    }

    // Tick object implementation
    if(obj->dynamic_tick != NULL) {
        obj->dynamic_tick(obj);
    }

    // Handle screen shakes, V & H
    if(obj->sprite_state.screen_shake_vertical > 0) {
        obj->gs->screen_shake_vertical = obj->sprite_state.screen_shake_vertical * 4;
        obj->sprite_state.screen_shake_vertical = 0;
    }
    if(obj->sprite_state.screen_shake_horizontal > 0) {
        obj->gs->screen_shake_horizontal = obj->sprite_state.screen_shake_horizontal * 4;
        obj->sprite_state.screen_shake_horizontal = 0;
    }
}
Esempio n. 3
0
File: player.c Progetto: deurk/ktx
void player_nail2()
{
	self->s.v.frame = 104;
	self->think = ( func_t ) player_nail1;
	self->s.v.nextthink = g_globalvars.time + 0.1;

	if ( !self->s.v.button0 || intermission_running || self->s.v.impulse )
	{
		self->walkframe = 0;
		player_run();
		return;
	}

	set_idealtime();
	muzzleflash();

	self->s.v.weaponframe = self->s.v.weaponframe + 1;
	if ( self->s.v.weaponframe >= 9 )
		self->s.v.weaponframe = 1;

	SuperDamageSound();
	W_FireSpikes( -4 );
	self->attack_finished = g_globalvars.time + 0.2;
	AmmoUsed (self);
}
Esempio n. 4
0
File: player.c Progetto: deurk/ktx
void player_stand1()
{
	self->s.v.frame = 17;
	self->think = ( func_t ) player_stand1;
	self->s.v.nextthink = g_globalvars.time + 0.1;

	self->s.v.weaponframe = 0;
	
	if ( self->s.v.velocity[0] || self->s.v.velocity[1] )
	{
		self->walkframe = 0;
		player_run();
		return;
	}

	if ( self->s.v.weapon == IT_AXE || self->s.v.weapon == IT_HOOK )
	{
		if ( self->walkframe >= 12 )
			self->walkframe = 0;
		self->s.v.frame = 17 + self->walkframe;
	} else
	{
		if ( self->walkframe >= 5 )
			self->walkframe = 0;
		self->s.v.frame = 12 + self->walkframe;
	}
	self->walkframe = self->walkframe + 1;
}
int main( int argc, char** argv )
{
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	Player *pPlayer = player_new();
	player_set_decoder( pPlayer, init_decoder() );
	player_set_display( pPlayer, init_display() );
	SDL_CreateThread( player_play, pPlayer );
	player_run( pPlayer );
	_CrtDumpMemoryLeaks();
	getchar();
	return 0;
}
Esempio n. 6
0
void MP3_test(void)
{
			/* 初始化设置I2S */
		I2S_Bus_Init();
		
		/* 初始化PCM1770 */
		PCM1770Init();
	
			/* 显示MP3界面图片 */
		Lcd_show_bmp(0, 0,"/mp3player/ui_window.bmp");

		/* 运行MP3播放器 */	
		player_run();
}
Esempio n. 7
0
/*
 * NAME:	main()
 * DESCRIPTION:	program entry point
 */
int main(int argc, char *argv[])
{
  struct player player;
  int result = 0;

  argv0 = argv[0];

  /* ensure binary standard I/O */

# if defined(_WIN32)
  _setmode(_fileno(stdin),  _O_BINARY);
  _setmode(_fileno(stdout), _O_BINARY);
# endif

  /* internationalization support */

# if defined(ENABLE_NLS)
  setlocale(LC_ALL, "");
  bindtextdomain(PACKAGE, LOCALEDIR);
  textdomain(PACKAGE);
# endif

  /* initialize and get options */

  player_init(&player);

# if !defined(__CYGWIN__)  /* Cygwin support for this is currently buggy */

  /* check for default tty control */

  if (isatty(STDIN_FILENO))
    player.options |= PLAYER_OPTION_TTYCONTROL;
# endif

  get_options(argc, argv, &player);

  /* main processing */

  if (player.verbosity >= 0)
    ver_banner(stderr);

  if (player.options & PLAYER_OPTION_CROSSFADE) {
    if (!(player.options & PLAYER_OPTION_GAP))
      warn(_("cross-fade ignored without gap"));
    else if (mad_timer_sign(player.gap) >= 0)
      warn(_("cross-fade ignored without negative gap"));
  }

  if (player.output.replay_gain & PLAYER_RGAIN_ENABLED) {
    if (player.options & PLAYER_OPTION_IGNOREVOLADJ)
      warn(_("volume adjustment ignored with Replay Gain enabled"));
    else
      player.options |= PLAYER_OPTION_IGNOREVOLADJ;
  }

  if ((player.options & PLAYER_OPTION_SHOWTAGSONLY) &&
      player.repeat != 1) {
    warn(_("ignoring repeat"));
    player.repeat = 1;
  }

  /* make stop time absolute */
  if (player.options & PLAYER_OPTION_TIMED)
    mad_timer_add(&player.global_stop, player.global_start);

  /* get default audio output module */
  if (player.output.command == 0 &&
      !(player.options & PLAYER_OPTION_SHOWTAGSONLY))
    player.output.command = audio_output(0);

# if defined(EXPERIMENTAL)
  if (external_mix) {
    player.options |= PLAYER_OPTION_EXTERNALMIX;
    player.output.command = 0;
  }
  if (experimental)
    player.options |= PLAYER_OPTION_EXPERIMENTAL;
# endif

  /* run the player */
  if (player_run(&player, argc - optind, (char const **) &argv[optind]) == -1)
    result = 4;

  /* finish up */
  player_finish(&player);

  return result;
}
Esempio n. 8
0
void W_SetCurrentAmmo()
{
	int             items;

 player_run ();          // get out of any weapon firing states
	items = self->s.v.items;
	items -= items & ( IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS );
	switch ( ( int ) self->s.v.weapon )
	{
	case IT_AXE:
		self->s.v.currentammo = 0;
		self->s.v.weaponmodel = "progs/v_axe.mdl";
		self->s.v.weaponframe = 0;
		break;

	case IT_SHOTGUN:
		self->s.v.currentammo = self->s.v.ammo_shells;
		self->s.v.weaponmodel = "progs/v_shot.mdl";
		self->s.v.weaponframe = 0;
		items |= IT_SHELLS;
		break;

	case IT_SUPER_SHOTGUN:
		self->s.v.currentammo = self->s.v.ammo_shells;
		self->s.v.weaponmodel = "progs/v_shot2.mdl";
		self->s.v.weaponframe = 0;
		items |= IT_SHELLS;
		break;

	case IT_NAILGUN:
		self->s.v.currentammo = self->s.v.ammo_nails;
		self->s.v.weaponmodel = "progs/v_nail.mdl";
		self->s.v.weaponframe = 0;
		items |= IT_NAILS;
		break;

	case IT_SUPER_NAILGUN:
		self->s.v.currentammo = self->s.v.ammo_nails;
		self->s.v.weaponmodel = "progs/v_nail2.mdl";
		self->s.v.weaponframe = 0;
		items |= IT_NAILS;
		break;

	case IT_GRENADE_LAUNCHER:
		self->s.v.currentammo = self->s.v.ammo_rockets;
		self->s.v.weaponmodel = "progs/v_rock.mdl";
		self->s.v.weaponframe = 0;
		items |= IT_ROCKETS;
		break;

	case IT_ROCKET_LAUNCHER:
		self->s.v.currentammo = self->s.v.ammo_rockets;
		self->s.v.weaponmodel = "progs/v_rock2.mdl";
		self->s.v.weaponframe = 0;
		items |= IT_ROCKETS;
		break;

	case IT_LIGHTNING:
		self->s.v.currentammo = self->s.v.ammo_cells;
		self->s.v.weaponmodel = "progs/v_light.mdl";
		self->s.v.weaponframe = 0;
		items |= IT_CELLS;
		break;

	default:
		self->s.v.currentammo = 0;
		self->s.v.weaponmodel = "";
		self->s.v.weaponframe = 0;
		break;
	}
	self->s.v.items = items;
}
Esempio n. 9
0
int main(int argc, char *argv[])
{
	int i,j, winner, field1_winner, numtasks, rounds=1, field_number, game_set;
	int score[3] = {0} ;
	time_t start,end;
	long long before, after ;
	double dif;


	Player_Match match;
	Player_Stats stats;
	MPI_Comm field_comm;
	Player_Match match_info[NPROCS-2];	// -2 field process
	MPI_Datatype MPI_MATCH ;	
	MPI_Init(&argc,&argv);
	MPI_Comm_size(MPI_COMM_WORLD, &numtasks);

	if (numtasks!=NPROCS) {
		printf("Must specify %d processors. Terminating.\n",NPROCS);
		MPI_Finalize();
		return 1;	
	}


	MPI_MATCH = createPlayerMatchStruct() ;
	MPI_Type_commit(&MPI_MATCH); 

	init_player_stats(&stats);

	init_team(&stats, &match);

	//Timing Code
	/* 
	time(&start);
	before = wall_clock_time() ;
	*/

	for (j=1; j<=2; j++) {
		init_player_match(&match) ;
		for (rounds=1, winner = -1, field1_winner=-1; rounds<=HALF_MATCH; rounds++, winner = -1, field1_winner=-1) {
			// inform players of ball coords
			if (stats.global_rank==FIELD) {
				for (i=1; i<NPROCS; i++)
					MPI_Send(match.ball_coords, 2, MPI_INT, i, T_inform_ball_coords, MPI_COMM_WORLD);
			}
			else {
				MPI_Recv(match.ball_coords, 2, MPI_INT, FIELD, T_inform_ball_coords, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
			}

			if (stats.global_rank!=FIELD_0 && stats.global_rank!=FIELD_1) {
				player_run(&match, &stats) ;
			}



			setup_field_comm(&stats, &match, &field_comm); 

			// send coordinates together with other info
			if (stats.court_rank==FIELD) {
				for (i=1; i<stats.court_group_size; i++)
					MPI_Recv(&match_info[i-1], 1, MPI_MATCH, i, T_report_pos, field_comm, MPI_STATUS_IGNORE);
			}
			else {
				MPI_Send(&match, 1, MPI_MATCH, 0, T_report_pos, field_comm);
			}

			// decide winner and inform players. Players in other field will not know who is the winner
			if (stats.court_rank==FIELD) {

				winner = decide_winner(match_info, stats.court_group_size-1) ;
				for (i=1; i<stats.court_group_size; i++)
				{
					MPI_Send(&winner, 1, MPI_INT, i, T_inform_winner, field_comm);

				}
			}
			else
			{
				MPI_Recv(&winner, 1, MPI_INT, FIELD, T_inform_winner, field_comm, MPI_STATUS_IGNORE);

			}


			if (winner!=-1) {

				if (stats.court_rank==winner) {
					// winner receives information of all players in same field 
					MPI_Recv(match_info, stats.court_group_size-1, MPI_MATCH, FIELD, T_players_on_field, field_comm, MPI_STATUS_IGNORE);
					shoot(match_info, &match, stats);

					// winner sends shoot location (negative for unsucessful shoot)
					MPI_Send(match.ball_coords, 2, MPI_INT, 0, T_inform_shoot_pos, field_comm);
				}

				if (stats.court_rank==FIELD)
				{	
					MPI_Send(match_info, stats.court_group_size-1, MPI_MATCH, winner, T_players_on_field, field_comm);
					MPI_Recv(match.ball_coords, 2, MPI_INT, winner, T_inform_shoot_pos, field_comm, MPI_STATUS_IGNORE);

					match_info[winner-1].ball_coords[0] = match.ball_coords[0] ;
					match_info[winner-1].ball_coords[1] = match.ball_coords[1] ;

					// decides the final position of ball
					choose_ballpos(match.ball_coords) ;
				}


			}

			// field 1 send to field 0 if it has more than 1 player in its court (not including itself)
			if (stats.global_rank==FIELD_1 && stats.court_group_size > 1) {
				MPI_Send(match_info, stats.court_group_size - 1, MPI_MATCH, FIELD_0, T_update_field0_player, stats.team_comm);

			}
			//field 0 receive from field 1 if it does not have all the players in its court (total processes - process of field 1)
			if (stats.global_rank==FIELD_0 && stats.court_group_size != NPROCS-1) {
				// buffer has an offset of no. of players in its court so that its own players will not be overwritten
				MPI_Recv(&match_info[stats.court_group_size - 1], NPROCS - stats.court_group_size -1, MPI_MATCH, FIELD_1, T_update_field0_player, stats.team_comm, MPI_STATUS_IGNORE);
			}

			// send the winner of field 1 to field 0
			if (stats.global_rank==FIELD_1) {
				MPI_Send(&winner, 1, MPI_INT, FIELD_0, T_winner_field1, MPI_COMM_WORLD);
			}
			if (stats.global_rank==FIELD_0) { 
				MPI_Recv(&field1_winner, 1, MPI_INT, FIELD_1, T_winner_field1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
			}

			// field 0 update ball coords there is a winner from field 1 
			if (winner!=-1 && stats.global_rank==FIELD_1) {
				MPI_Send(match.ball_coords, 2, MPI_INT, FIELD_0, T_update_field0_ball, MPI_COMM_WORLD);
			}
			if (winner==-1 && stats.global_rank==FIELD_0 && field1_winner!=-1)
				MPI_Recv(match.ball_coords, 2, MPI_INT, FIELD_1, T_update_field0_ball, MPI_COMM_WORLD, MPI_STATUS_IGNORE);

			if (stats.global_rank==FIELD_0) {
				printf("%d\n", rounds*j) ; 
				print_round_info(match_info, score, match.ball_coords);

			}
			else {
				match.ball_coords[0] = INVALID_COORDS;
				match.ball_coords[1] = INVALID_COORDS;
				match.initial_coords[0] = match.final_coords[0] ;
				match.initial_coords[1] = match.final_coords[1] ;
			}

			MPI_Comm_free(&field_comm);
		}

		if (match.team == 1) {
			stats.post[0] = 128;
		}
		else if  (match.team == 2) {
			stats.post[0] = 0;
		}
	}

	//Timing Code
	/*
	if (stats.global_rank==FIELD_0) {
	time(&end);	
	/dif = difftime (end,start);
	after = wall_clock_time() ;
	printf ("It took %.5lf seconds to complete 5400 rounds (time.h).\n", dif );
	printf ("It took %.5lf seconds to complete 5400 rounds (linux time).\n", (float)(after-before)/1000000000.0);
	printf ("It took %.5lf milliseconds to complete 1 rounds (linux time).\n", (float)(after-before)/(5400*1000000.0));
	}
	*/
	MPI_Finalize();
	return 0;
}