Exemple #1
0
/*
-----------------------------------------------------------------------------
 Function: Changes player's angle and position
 
 Parameters:
 
 Returns:
 
 Notes: 

-----------------------------------------------------------------------------
*/
PRIVATE void PL_ControlMovement( player_t *self, LevelData_t *lvl )
{
	int angle, speed;

// rotation
	angle = self->position.angle;

//	if(cmd->forwardmove || cmd->sidemove)
		self->movx = self->movy = 0; // clear accumulated movement

	if( Player.cmd.forwardmove )
	{
		speed = tics * Player.cmd.forwardmove;
		self->movx+=(int)(speed * CosTable[ angle ] );
		self->movy+=(int)(speed * SinTable[ angle ] );
	}
	if( Player.cmd.sidemove )
	{
		speed = tics * Player.cmd.sidemove;
		self->movx += (int)( speed * SinTable[ angle ] );
		self->movy -= (int)( speed * CosTable[ angle ] );
	}

	if( ! self->movx && ! self->movy ) 
		return;
	
#ifdef SPEAR

	funnyticount = 0; // ZERO FUNNY COUNTER IF MOVED! // FIXME!

#endif
	self->speed = self->movx + self->movy;

// bound movement
	if( self->movx > MAXMOVE ) 
		self->movx = MAXMOVE;
	else if( self->movx < -MAXMOVE ) 
		self->movx = -MAXMOVE;

	if( self->movy > MAXMOVE ) 
		self->movy = MAXMOVE;
	else if( self->movy < -MAXMOVE ) 
		self->movy = -MAXMOVE;

// move player and clip movement to walls (check for no-clip mode here)
	PL_ClipMove( self, self->movx, self->movy );
	self->tilex = POS2TILE( self->position.origin[ 0 ] );
	self->tiley = POS2TILE( self->position.origin[ 1 ] );

	// pick up items easier -- any tile you touch, instead of
	// just the midpoint tile
	{
		int	x, y;
		
		for ( x = -1 ; x <= 1 ; x+= 2 ) {
			int	tilex = POS2TILE( self->position.origin[0] + x * PLAYERSIZE );
			for ( y = -1 ; y <= 1 ; y+= 2 ) {
				int	tiley = POS2TILE( self->position.origin[1] + y * PLAYERSIZE );
				Powerup_PickUp( tilex, tiley );
			}
		}
	}
//	Powerup_PickUp( self->tilex, self->tiley );

// Checking for area change, ambush tiles and doors will have negative values
	if( lvl->areas[ self->tilex ][ self->tiley ] >= 0 &&
		lvl->areas[ self->tilex ][ self->tiley ] != Player.areanumber )
	{
		Player.areanumber = lvl->areas[ self->tilex ][ self->tiley ];
		assert( Player.areanumber >= 0 && Player.areanumber < NUMAREAS );
		Areas_ConnectAreas( Player.areanumber );
	}

	if( lvl->tilemap[ self->tilex ][ self->tiley ] & EXIT_TILE )
	{
		iphoneStartIntermission( 0 );
	}
	

}
Exemple #2
0
/**
 * \brief Changes player's angle and position
 * \param[in] self Player
 * \param[in] lvl Level data structure
 */
PRIVATE void PL_ControlMovement( player_t *self, LevelData_t *lvl )
{
	int speed;
    float angle;

// rotation
    angle = self->position.angle;

//	if(cmd->forwardmove || cmd->sidemove)
		self->movx = self->movy = 0; // clear accumulated movement

	if( ClientState.cmd.forwardmove )
	{
		speed = tics * ClientState.cmd.forwardmove;
		self->movx += (int)(speed * cos( angle ) );
		self->movy += (int)(speed * sin( angle ) );
	}
	if( ClientState.cmd.sidemove )
	{
		speed = tics * ClientState.cmd.sidemove;
		self->movx += (int)( speed * sin( angle ) );
		self->movy -= (int)( speed * cos( angle  ) );
	}

	if( !self->movx && !self->movy )
		return;

#ifdef SPEAR

	funnyticount = 0; // ZERO FUNNY COUNTER IF MOVED! // FIXME!

#endif
	self->speed = self->movx + self->movy;

// bound movement
	if( self->movx > MAXMOVE )
    {
		self->movx = MAXMOVE;
    }
	else if( self->movx < -MAXMOVE )
    {
		self->movx = -MAXMOVE;
    }

	if( self->movy > MAXMOVE )
    {
		self->movy = MAXMOVE;
    }
	else if( self->movy < -MAXMOVE )
    {
		self->movy = -MAXMOVE;
    }

// move player and clip movement to walls (check for no-clip mode here)
	PL_ClipMove( self, self->movx, self->movy );
	self->tilex = POS2TILE( self->position.origin[ 0 ] );
	self->tiley = POS2TILE( self->position.origin[ 1 ] );

	Powerup_PickUp( self->tilex, self->tiley );

// Checking for area change
	if( lvl->areas[ self->tilex ][ self->tiley ] >= 0 &&
		lvl->areas[ self->tilex ][ self->tiley ] != Player.areanumber )
	{
		Player.areanumber = lvl->areas[ self->tilex ][ self->tiley ];
		Areas_Connect( Player.areanumber );
	}

	if( lvl->tilemap[ self->tilex ][ self->tiley ] & EXIT_TILE )
	{
        SpawnBJVictory();
	}


}