コード例 #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;
    }
}
コード例 #2
0
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);
}
コード例 #3
0
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);
}
コード例 #4
0
void CRedShot::processMove()
{
  if( blockedl || blockedr || blockedu || blockedd )
    setAction(A_REDSHOT_SMASH);

  moveXDir(xDirection*MOVE_X_SPEED);
  moveYDir(yDirection*MOVE_Y_SPEED);  
}
コード例 #5
0
void CIceBit::process()
{
	moveXDir(veloc_x);
	moveYDir(veloc_y);

	if (timer <= 0)
		exists = false;
	else
		timer--;
}
コード例 #6
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);
  }
      
}
コード例 #7
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;
	}
}
コード例 #8
0
void CScrub::process()
{    
	CCarrier::process();
    
	if (canbezapped)
	{
		// die if shot
		if (mHealthPoints <= 0 && state!=SCRUB_DYING )
		{
			solid=true;
			state = SCRUB_DYING;
			dietimer = 0;
			moveUp(10);
			scrubdie_inertia_y = SCRUBDIE_START_INERTIA;
			playSound(SOUND_SHOT_HIT);
		}
	}

	CPhysicsSettings &Physics = g_pBehaviorEngine->getPhysicsSettings();

	switch(state)
	{
	case SCRUB_DYING:
		sprite = SCRUB_FRY_FRAME;
		moveYDir(scrubdie_inertia_y);
		if ( scrubdie_inertia_y < Physics.max_fallspeed )
			scrubdie_inertia_y += Physics.fallspeed_increase;

		dietimer = 0;
		if (scrubdie_inertia_y >= 0 && blockedd)
		{
			sprite = SCRUB_DEAD_FRAME;
			state = SCRUB_DEAD;
			dead = true;
		}
		return;
		break;
	case SCRUB_WALK:


		if(xDirection < 0)
			walkLeft( (getXLeftPos())>>CSF, (getYMidPos())>>CSF);
		else if(xDirection > 0)
			walkRight( (getXRightPos())>>CSF, (getYMidPos())>>CSF);
		else if(yDirection < 0)
コード例 #9
0
bool CPlayer::checkObjSolid()
{
	if(pSupportedbyobject)
	{
		pfalling = false;
		if(pjumping == PJUMPLAND)
		    pjumping = PNOJUMP;
		
		int dy = pSupportedbyobject->getYPosition() - getYDownPos()+3;
		if(pjumping == PNOJUMP)
		{
		    moveYDir(dy);
		}
		blockedd = true;		
	}
	
	return true;
}
コード例 #10
0
ファイル: Autogun.cpp プロジェクト: z33ky/Commander-Genius
// 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();
}
コード例 #11
0
// handles inertia and friction for the Y direction
// (this is where the inertia is actually applied to playx)
void CPlayer::InertiaAndFriction_Y()
{
	if (hideplayer)
	{
		pinertia_y = 0;
		return;
	}
	
	// if we hit a solid object kill all inertia
	if (pinertia_y > 0 && blockedd)
		pinertia_y = 0;
	else if (pinertia_y < 0 && blockedu)
		pinertia_y = 0;
	else if( isWMSolid(getXMidPos(), getYMidPos()) )
		pinertia_y = 0;


	// then apply pinertia_y
	if( (!blockedu && pinertia_y<0) || (!blockedd && pinertia_y>0) )
		moveYDir(pinertia_y);
	
	// if we stopped walking (i.e. LRUD not held down) apply friction
    if (playcontrol[PA_Y] == 0)
    {
		// and apply friction to pinertia_y
		if (pinertia_y < 0)
		{
			pinertia_y += PFRICTION_RATE_WM<<4;
			if(pinertia_y > 0) pinertia_y = 0;
		}
		else if (pinertia_y > 0)
		{
			pinertia_y -= PFRICTION_RATE_WM<<4;
			if(pinertia_y < 0) pinertia_y = 0;
		}
    }
}
コード例 #12
0
ファイル: CBlorb.cpp プロジェクト: akien-mga/Commander-Genius
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;
	}
}