Beispiel #1
0
void CEnemyShot::process()
{    
    m_speedInt += m_speedF;

    if(m_speedInt >= 1.0)
    {
        const int speed = m_speedInt;

        moveXDir(speed*xDirection);
        moveYDir(speed*yDirection);

        m_speedInt -= float(speed);
    }

    
    // If it collides against something, make it non-existent
    if( (blockedd && yDirection == DOWN) ||
            (blockedl && xDirection == LEFT) ||
            (blockedu && yDirection == UP) ||
            (blockedr && xDirection == RIGHT) )
    {
        exists = false;
    }
    
    if(!processActionRoutine())
    {
        exists = false;
    }
}
Beispiel #2
0
void CShellyFrags::process()
{
	performCollisions();
	
	performGravityMid();

	// Reflections at wall. Not sure, if it makes sense, let's observe the behaviour
	if( (blockedl && mXSpeed < 0) ||
	    (blockedr && mXSpeed > 0) )
	{
	  mXSpeed = -mXSpeed;
	}		
	
	if( blockedd )
	{
	  dead = true;
	  exists = false;
	  return;
	}
	
	
	moveXDir(mXSpeed);
	
	processActionRoutine();	
}
Beispiel #3
0
void CAmpton::processPoleSlide()
{
    
  int l_x_l = getXLeftPos();
  int l_x = getXMidPos();
  int l_x_r = getXRightPos();
  int l_y_mid = getYMidPos();
  int l_y_down = getYDownPos();	
  
  // Move normally in the direction
  if( yDirection == UP )
  {    
	// Check for the upper side and don't let him move if the pole ends
	if( hitdetectWithTileProperty(1, l_x_l, l_y_mid) ||
	    hitdetectWithTileProperty(1, l_x, l_y_mid) ||
	    hitdetectWithTileProperty(1, l_x_r, l_y_mid) )
	{
		moveUp( SLIDE_SPEED );
	}
	else
	{
		yDirection = DOWN;
	}	
  }
  else // Down
  {
	// Check for the upper side and don't let him move if the pole ends
	if( hitdetectWithTileProperty(1, l_x_l, l_y_down) ||
	    hitdetectWithTileProperty(1, l_x, l_y_down) ||
	    hitdetectWithTileProperty(1, l_x_r, l_y_down) )
	{
		moveDown( SLIDE_SPEED );
	}
	else
	{
		yDirection = UP;
	}    
  }
  
  mTimer++;
  if(mTimer < UMOUNT_TIME)
    return;
  
  mTimer = 0;
  
  // Check for Floor here!        
  const int fall1 = mp_Map->getPlaneDataAt(1, l_x, l_y_down+(1<<CSF));
  //const int fall1 = mp_Map->getPlaneDataAt(1, l_x, l_y_down);
  const CTileProperties &TileProp1 = g_pBehaviorEngine->getTileProperties(1)[fall1];
  const bool leavePole = (TileProp1.bup != 0);
  
  if(leavePole)
  {
    setAction(A_AMPTON_STOP_POLE);
    moveXDir(2*xDirection*WALK_SPEED);
    moveUp(1<<CSF);
    solid = true;
    blockedd = true;
  }
}
void CIceChunk::process()
{
	// smash the chunk if it hits something
	if (vector_x > 0)
	{
		if (blockedr) { smash(); return; }
	}
	else if (vector_x < 0)
	{
		if (blockedl) { smash(); return; }
	}

	if (vector_y > 0)
	{
		if (blockedd) { smash(); return; }
	}
	else if (vector_y < 0)
	{
		if (blockedu) { smash(); return; }
	}

	// fly through the air
	moveXDir(veloc_x);
	moveYDir(veloc_y);
}
void CIceChunk::process()
{
	// freeze the player if it touches him
	if (touchPlayer)
	{
		CPhysicsSettings &Physics = g_pBehaviorEngine->getPhysicsSettings();
		// make him start sliding in the direction of the impact
		if (vector_x > 0)
		{
			m_Player[touchedBy].pdir = m_Player[touchedBy].pshowdir = RIGHT;
			m_Player[touchedBy].xinertia = Physics.player.max_x_speed;
			m_Player[touchedBy].bump( *this, RIGHT );
		}
		else if (vector_x < 0)
		{
			m_Player[touchedBy].pdir = m_Player[touchedBy].pshowdir = LEFT;
			m_Player[touchedBy].xinertia = -Physics.player.max_x_speed;
			m_Player[touchedBy].bump( *this, LEFT );
		}
		else	// perfectly vertical ice cannons
		{
			const int UPDNCANNON_PUSHAMT = 16;
			if (m_Player[touchedBy].xinertia < UPDNCANNON_PUSHAMT)
			{
				if (rnd()&1)
					m_Player[touchedBy].xinertia = UPDNCANNON_PUSHAMT;
				else
					m_Player[touchedBy].xinertia = -UPDNCANNON_PUSHAMT;
			}
		}

		m_Player[touchedBy].freeze();
		smash();
		return;
	}

	// smash the chunk if it hits something
	if (vector_x > 0)
	{
		if (blockedr) { smash(); return; }
	}
	else if (vector_x < 0)
	{
		if (blockedl) { smash(); return; }
	}

	if (vector_y > 0)
	{
		if (blockedd) { smash(); return; }
	}
	else if (vector_y < 0)
	{
		if (blockedu) { smash(); return; }
	}

	// fly through the air
	moveXDir(veloc_x);
	moveYDir(veloc_y);
}
Beispiel #6
0
void CShelly::processFall()
{

    moveXDir(xDirection*JUMP_X_SPEED);
    
    if(blockedd)
	setAction(A_SHELLY_SMASH);
}
void CRedShot::processMove()
{
  if( blockedl || blockedr || blockedu || blockedd )
    setAction(A_REDSHOT_SMASH);

  moveXDir(xDirection*MOVE_X_SPEED);
  moveYDir(yDirection*MOVE_Y_SPEED);  
}
void CIceBit::process()
{
	moveXDir(veloc_x);
	moveYDir(veloc_y);

	if (timer <= 0)
		exists = false;
	else
		timer--;
}
Beispiel #9
0
void CSpirogrip::processMove()
{
  // Move normally in the direction
  moveXDir( xDirection*MOVE_SPEED );
  moveYDir( yDirection*MOVE_SPEED );
  
  if( blockedl )
  {
    xDirection = RIGHT;
    yDirection = CENTER;
    setAction(A_GRIP_BACK_UP_RIGHT);    
  }
  else if( blockedr )
  {
    xDirection = LEFT;
    yDirection = CENTER;
    setAction(A_GRIP_BACK_UP_LEFT);
  }
	
  if( blockedu )
  {
    xDirection = CENTER;
    yDirection = UP;
    setAction(A_GRIP_BACK_UP_UP);
  }
  else if( blockedd )
  {
    xDirection = CENTER;
    yDirection = DOWN;
    setAction(A_GRIP_BACK_UP_DOWN);
  }
  
  mTimer++;
  if( mTimer < TIME_UNTIL_BACKUP )
      return;
  
  mTimer = 0;
  
  if(getProbability(500))
  {            
      if(xDirection == LEFT)
	  setAction(A_GRIP_BACK_UP_LEFT);
      else if(xDirection == RIGHT)
	  setAction(A_GRIP_BACK_UP_RIGHT);
      
      if(yDirection == UP)
	  setAction(A_GRIP_BACK_UP_UP);
      else if(yDirection == DOWN)
	  setAction(A_GRIP_BACK_UP_DOWN);
  }
      
}
Beispiel #10
0
void CSlicestar::process()
{
	performCollisions();

	if(mUseBlocker)
	{
	  const Uint16 object = mpMap->getPlaneDataAt(2, getPosition());
	
	  // If there is a blocker, change the direction
	  if( object == 0x1F )
	  {
	    if(xDirection != CENTER)
	      xDirection = -xDirection;
	      
	    if(yDirection != CENTER)
	      yDirection = -yDirection;
	  }

	}

	// Move normally in the direction
	moveXDir( xDirection*MOVE_SPEED );
	moveYDir( yDirection*MOVE_SPEED );	
	
	if( blockedl && xDirection == LEFT )
	{
	  playSound(SOUND_SLICEBUMP);
	  xDirection = RIGHT;
	}
	else if(blockedr && xDirection == RIGHT)
	{
	  playSound(SOUND_SLICEBUMP);
	  xDirection = LEFT;
	}

	if( blockedu && yDirection == UP )
	{
	  playSound(SOUND_SLICEBUMP);
	  yDirection = DOWN;
	}
	else if(blockedd && yDirection == DOWN)
	{
	  playSound(SOUND_SLICEBUMP);
	  yDirection = UP;
	}
}
Beispiel #11
0
void CShelly::processWalking()
{ 
    
    if( blockedl )
    {
	xDirection = RIGHT;
    }
    else if(blockedr)
    {
	xDirection = LEFT;
    }
    
    // Move normally in the direction
    moveXDir(xDirection*WALK_SPEED);   
        
    if(mGoodJumpChance)
    {
	setAction(A_SHELLY_PREPARE_JUMP);
    }
}
Beispiel #12
0
// When autogun is waiting to shoot!
void AutoShot::flying()
{    
  moveXDir(xDirection*FLY_SPEED);
  moveYDir(yDirection*FLY_SPEED);
    
  sprite = mBaseSprite + (mTimer % mNumAnimSprites);
  
  if(yDirection == DOWN && blockedd)
    setWaitStatus();
  else if(yDirection == UP && blockedu)
    setWaitStatus();

  if(xDirection == LEFT && blockedl)
    setWaitStatus();
  else if(xDirection == RIGHT && blockedr)
    setWaitStatus();  
  
  if(onslope)
      setWaitStatus();
}
Beispiel #13
0
void CBlorb::processMoving()
{
	// Move normally in the direction
	moveXDir( xDirection*MOVE_SPEED );
	moveYDir( yDirection*MOVE_SPEED );	
	
	if( blockedl && xDirection == LEFT )
	{
	  xDirection = RIGHT;
	}
	else if(blockedr && xDirection == RIGHT)
	{
	  xDirection = LEFT;
	}

	if( blockedu && yDirection == UP )
	{
	  yDirection = DOWN;
	}
	else if(blockedd && yDirection == DOWN)
	{
	  yDirection = UP;
	}
}
Beispiel #14
0
// handles inertia and friction for the X direction
// (this is where the xinertia is actually applied to playx)
void CPlayer::InertiaAndFriction_X()
{
	int friction_rate;
	treshold = 0;
	CPhysicsSettings &PhysicsSettings = g_pBehaviorEngine->getPhysicsSettings();


	// Calculate Threshold of your analog device for walking animation speed!
	if(!pfrozentime && !pfiring)
	{
		treshold = playcontrol[PA_X];

		int pmaxspeed;
		int pmaxmovespeed = PhysicsSettings.player.max_x_speed;


		if( (!pjumping && !pfalling &&
				!psemisliding && !psliding && !ppogostick && !pslowingdown) || m_playingmode==WORLDMAP )
		{
			if(treshold < playcontrol[PA_Y] && playcontrol[PA_Y] > 0 )
				treshold = playcontrol[PA_Y];

			if(treshold > playcontrol[PA_Y] && playcontrol[PA_Y] < 0 )
				treshold = playcontrol[PA_Y];

			if(treshold < 0)
				treshold *= (-1);
		}
		else	treshold = 100;

		pmaxspeed = treshold*pmaxmovespeed/100;

		if(xinertia > pmaxspeed)
			xinertia = pmaxspeed;
		if(xinertia < -pmaxspeed)
			xinertia = -pmaxspeed;
	}

    const int ep = g_pBehaviorEngine->getEpisode();
    const int level = mp_Map->getLevel();

    if(level == 80) // We are on World map
		verifySolidLevels();
	
	// apply xinertia
    // (unless we're about to make a pogo or jump)
	if ( pjumping != PPREPAREPOGO && pjumping != PPREPAREJUMP)
	{
		int dx = xinertia;
		// check first if the player is not blocked
		if( (!blockedr and dx>0 ) or 
		    (!blockedl and dx<0 ) )
			moveXDir(dx);
		else
			xinertia = 0;
	}
	
	// if we stopped walking (i.e. left or right not held down) apply friction
	// there's no friction if we're semisliding

	if ( ( playcontrol[PA_X] == 0 || pfiring ) && !psemisliding)
	{
		// determine friction rate--different rates for on ground and in air
		if (m_playingmode == WORLDMAP)
		{
			friction_rate = PFRICTION_RATE_WM;
		}
		else
		{
			friction_rate = (!pfalling && !pjumping) ? PFRICTION_RATE_ONGROUND : PFRICTION_RATE_INAIR;
		}
		
		// and apply friction to xinertia
		// when pogoing apply friction till we get down to PFASTINCMAXSPEED
		// then stop the friction
		if (!ppogostick || (xinertia >  PhysicsSettings.player.max_x_speed) ||
						   (xinertia < -PhysicsSettings.player.max_x_speed) )
		{
            if (!pfrozentime || ep != 1)
			{   // disable friction while frozen
				// here the wall animation must be applied!
				if(!psliding)
				{
					if( (xinertia>0 && blockedr) ||
						(xinertia<0 && blockedl) )
					{
						friction_rate = 3*friction_rate;
					}

                    if(pfalling)
                        friction_rate /= 2;

					decreaseXInertia(friction_rate);
				}
			}
		}
	}
}