Example #1
0
void CK6_GikSlide(CK_object *obj)
{
	CK_PhysGravityHigh(obj);

	int topflag = obj->topTI & 7;
	uint16_t di = obj->xDirection == IN_motion_Right ? gikslides_r[topflag] : gikslides_l[topflag];
	if (obj->velX == 0 && obj->topTI)
	{
		// Hit a wall and on the ground
		obj->currentAction = CK_GetActionByName("CK6_ACT_GikEndSlide0");
	}
	else
	{
		// Slide to a halt
		int32_t lastTimeCount = SD_GetLastTimeCount();
		for (int32_t tickCount = lastTimeCount - SD_GetSpriteSync(); tickCount < lastTimeCount; tickCount++)
		{
			if (di)
			{
				uint32_t ddi = di;
				if ((ddi & tickCount) == 0)
				{
					if ((obj->velX < 0 && ++obj->velX == 0) || (obj->velX > 0 && --obj->velX == 0))
					{
						obj->currentAction = CK_GetActionByName("CK6_ACT_GikEndSlide0");
						break;
					}
				}
			}
			ck_nextX += obj->velX;
		}
	}
}
Example #2
0
void CK6_BipshipFly(CK_object *obj)
{
	CK_PhysAccelHorz(obj, obj->xDirection, 20);
	int xdir = obj->xDirection;
	int ycheck = ck_keenObj->clipRects.unitY2 + 0x100 - obj->clipRects.unitY2;
	if (ycheck <= 0x200 && ycheck >= 0)
	{
		// Fire!!
		xdir = (ck_keenObj->posX < obj->posX) ? IN_motion_Left : IN_motion_Right;
		if (obj->xDirection == xdir && US_RndT() < SD_GetSpriteSync() * 2)
		{
			SD_PlaySound(SOUND_KEENSHOOT);
			CK_object *shot = CK_GetNewObj(true);
			shot->type = CT6_EnemyShot;
			shot->active = OBJ_EXISTS_ONLY_ONSCREEN;
			shot->zLayer = PRIORITIES - 3;
			if (obj->xDirection == IN_motion_Right)
			{
				shot->posX = obj->posX + 0x100;
				shot->velX = 64;
			}
			else
			{
				shot->posX = obj->posX;
				shot->velX = -64;
			}

			shot->posY = obj->posY + 0xA0;
			shot->velY = 16;
			CK_SetAction(shot, CK_GetActionByName("CK6_ACT_BipShot0"));
		}
	}

	int startx = obj->clipRects.tileXmid + 2 * xdir;
	int y = obj->clipRects.tileY1;
	uint16_t *tile = CA_TilePtrAtPos(startx, y, 1);

	for (y; y <= obj->clipRects.tileY2; y++, tile += CA_GetMapWidth())
	{
		if (TI_ForeLeft(*tile) || TI_ForeRight(*tile))
		{
			xdir = -xdir;
			goto checkTurn;
		}
	}

	// And turn around at ledge-ends
	if (!TI_ForeTop(*tile))
		xdir = -xdir;

checkTurn:

	if (obj->xDirection != xdir)
	{
		obj->xDirection = xdir;
		CK_SetAction2(obj, CK_GetActionByName("CK6_ACT_BipshipTurn0"));
	}
}
Example #3
0
void CK6_OrbatrixUncurlThink(CK_object *obj)
{
	ck_nextY = SD_GetSpriteSync() * -8;
	obj->user2 += ck_nextY;
	if (obj->user2 <= 0)
	{
		ck_nextY -= obj->user2;
		obj->currentAction = obj->currentAction->next;
	}
}
Example #4
0
void CK6_OrbatrixDraw(CK_object *obj)
{
	obj->posY -= obj->user3;
	CK_BasicDrawFunc2(obj);
	obj->posY += obj->user3;

	obj->user3 += obj->user4 * SD_GetSpriteSync() * 4;

	if (obj->user3 > 0x80)
	{
		obj->user3 = 0x80;
		obj->user4 = -1;
	}
	else if (obj->user3 < -0x80)
	{
		obj->user3 = -0x80;
		obj->user4 = 1;
	}
}
Example #5
0
void CK6_RocketFly(CK_object *obj)
{
  if (!ck_nextX && !ck_nextY)
  {
    if (!SD_SoundPlaying())
      SD_PlaySound(SOUND_ROCKETFLY);

    int delta = SD_GetSpriteSync() * 32;

    // Will we reach a new tile?
    if (obj->user2 > delta)
    {
      // No... keep moving in the same direction.
      obj->user2 -= delta;

      int dirX = ck_infoplaneArrowsX[obj->user1];
      if (dirX == 1)
      {
        // Moving right.
        ck_nextX += delta;
      }
      else if (dirX == -1)
      {
        // Moving left
        ck_nextX -= delta;
      }

      int dirY = ck_infoplaneArrowsY[obj->user1];
      if (dirY == 1)
      {
        // Moving down
        ck_nextY += delta;
      }
      else if (dirY == -1)
      {
        // Moving up
        ck_nextY -= delta;
      }
    }
    else
    {
      // Move to next tile.
      int dirX = ck_infoplaneArrowsX[obj->user1];
      if (dirX == 1)
      {
        // Moving right.
        ck_nextX += obj->user2;
      }
      else if (dirX == -1)
      {
        // Moving left
        ck_nextX -= obj->user2;
      }

      int dirY = ck_infoplaneArrowsY[obj->user1];
      if (dirY == 1)
      {
        // Moving down
        ck_nextY += obj->user2;
      }
      else if (dirY == -1)
      {
        // Moving up
        ck_nextY -= obj->user2;
      }

      int tileX = (uint16_t)RF_UnitToTile(obj->posX + ck_nextX);
      int tileY = (uint16_t)RF_UnitToTile(obj->posY + ck_nextY);

      obj->user1 = CA_TileAtPos(tileX, tileY, 2) - 0x5B;

      if ((obj->user1 < 0) || (obj->user1 > 8))
      {
        obj->posX += ck_nextX;
        obj->posY += ck_nextY;
        CK_SetAction2(obj, CK_GetActionByName("CK6_ACT_RocketSit0"));

        ck_keenObj->posX = RF_TileToUnit(tileX + 1) + 0x10;
        ck_keenObj->posY = RF_TileToUnit(tileY + 1);
        ck_keenObj->type = CT_Player;
        ck_keenObj->gfxChunk = 0xBD;
        ck_keenObj->clipped = CLIP_normal;
        CK_SetAction(ck_keenObj, CK_GetActionByName("CK_ACT_MapKeenStart"));
        ck_gameState.ep.ck6.inRocket ^= 1;
        return;
      }

      delta -= obj->user2;
      obj->user2 = 256 - delta;

      // Move in the new direction.
      dirX = ck_infoplaneArrowsX[obj->user1];
      if (dirX == 1)
      {
        // Moving right.
        ck_nextX += delta;
      }
      else if (dirX == -1)
      {
        // Moving left
        ck_nextX -= delta;
      }

      dirY = ck_infoplaneArrowsY[obj->user1];
      if (dirY == 1)
      {
        // Moving down
        ck_nextY += delta;
      }
      else if (dirY == -1)
      {
        // Moving up
        ck_nextY -= delta;
      }
    }
  }
}