Exemplo n.º 1
0
void GBomb::ServerThink(Uint32 time)
{
  GEntity::ServerThink(time);

  rect_t r1;
  GetBoundingBox(&r1);

  me = this;
  if (movementx)
  {
    MoveBoundingBox(&r1, movementx, 0);
    if (!GlobalCollision(&r1, GBombObjColB))
    {
      xpos = xpos + movementx;
      NormalizePos();
      moved = true;
    }
    else
    {
      movementx=0;
      movementy=0;
      if (moved) CloneSound(SM_NARAZ, 0, 0);
      moved = false;
    }
  }
  
  if (movementy)
  {
    MoveBoundingBox(&r1, 0, movementy);
    if (!GlobalCollision(&r1, GBombObjColB))
    {
      ypos = ypos + movementy;
      NormalizePos();
      moved = true;
    }
    else
    {
      movementx=0;
      movementy=0;
      if (moved) CloneSound(SM_NARAZ, 0, 0);
      moved = false;
    }
  }

  // do test collisions, hurting players, random actions, and so on
  if (anim==1 && frame==sprite->anims[anim]->frames-1)
  {
    state = 0;
  }

  if (anim==0 && curtime>=explode_time)
    Explode();
}
Exemplo n.º 2
0
//==========================================================================*
// Find index of section to position
//--------------------------------------------------------------------------*
int TTrackDescription::IndexFromPos(double TrackPos) const
{
  TrackPos = NormalizePos(TrackPos);             // Normalize to >= 0.0

  int Index = int(                               // Estimate index from
	floor(TrackPos/oMeanSectionLen)) % oCount;   // distance to startline
  Index = oSections[Index].PosIndex;             // Use lookup table

  // Interpolate back from estimation
  while (TrackPos < oSections[Index].DistFromStart)
  {
	if (Index > 0)
      Index--;
	else
      return 0;
  }

  // Interpolate from estimation
  while (TrackPos > oSections[Index+1].DistFromStart)
  {
    if (Index < oCount - 2)
      Index++;
	else
      return oCount - 1;
  }

// Wheel-2: >>>
  if (Index < 2)
	  return 2;
  else if (Index > oCount - 2)
	  return oCount - 2;
  else
// <<< Wheel-2
	  return Index;
}
Exemplo n.º 3
0
//==========================================================================*
// Calc cars position from offset
//--------------------------------------------------------------------------*
double TTrackDescription::CalcPos(tCarElt* Car, double Offset) const
{
  double Pos = RtGetDistFromStart(Car) + Offset;
  return NormalizePos(Pos);                      // Normalize to >= 0.0
}
Exemplo n.º 4
0
//==========================================================================*
// Calc position from offset
//--------------------------------------------------------------------------*
double TTrackDescription::CalcPos(tTrkLocPos& TrkPos, double Offset) const
{
  double Pos = RtGetDistFromStart2(&TrkPos) + Offset;
  return NormalizePos(Pos);                      // Normalize to >= 0.0
}