Ejemplo n.º 1
0
void Tetronimo::Turn(bool clockwise)
{
	int i = 0;
	Point posChange;
	Point p;
	Point topLeft = grid->GetGridTopLeft();
	//turn
	for(i=0;i<4;i++)
	{
		if(i==0)
		{
			posChange.x = squares[i].x + turnAxis.x - topLeft.x;
			posChange.y = squares[i].y + turnAxis.y - topLeft.y;;
		}

		p = grid->GetTurnPoint(grid->GetPoint(squares[i].x, squares[i].y), clockwise, posChange);
		squares[i].x = p.x;
		squares[i].y = p.y;
		if(i==0)
		{
			SetTurnAxis(+posChange.x - squares[i].x + topLeft.x, +posChange.y - squares[i].y + topLeft.y);
		}
	}
	UpdateMovement();
}
Ejemplo n.º 2
0
void Ghost::Update( float dt )
{
    UpdateMovement( dt );
    light.Update( dt );

    if( Tree::GetSettings()->GetValue<bool>( "debug_ghost" ) ) {
        std::stringstream s;
        s << "pos: " << pos.x << " " << pos.y;
        Tree::Debug( s.str() );
        s.str("");

        s << "vel: " << vel.x << " " << vel.y;
        Tree::Debug( s.str() );
        s.str("");

        s << "stop: " << stop_pos.x << " " << stop_pos.y;
        Tree::Debug( s.str() );
        s.str("");

        s << "next: " << next_move.x << " " << next_move.y;
        Tree::Debug( s.str() );
        s.str("");

        s << "face_dir: " << face_dir.x << " " << face_dir.y;
        Tree::Debug( s.str() );
        s.str("");
    }
}
Ejemplo n.º 3
0
void Tetronimo::Move(MoveType movType)
{
	int i = 0;
	Point p;
	for(i=0;i<4;i++)
	{
		switch(movType)
		{
		case Left:
			p = grid->GetMovePointLeft(grid->GetPoint(squares[i].x, squares[i].y));
			squares[i].x = p.x;
			squares[i].y = p.y;
			break;
		case Right:
			p = grid->GetMovePointRight(grid->GetPoint(squares[i].x, squares[i].y));
			squares[i].x = p.x;
			squares[i].y = p.y;
			break;
		case Down:
			p = grid->GetMovePointDown(grid->GetPoint(squares[i].x, squares[i].y));
			squares[i].x = p.x;
			squares[i].y = p.y;
			break;
		}

	}
	UpdateMovement();
}
Ejemplo n.º 4
0
void Tetronimo::Create(int x, int y, int random)
{
	
	switch(random)
	{
	case 1:
		Create1(x, y);
		break;
	case 2:
		Create2(x, y);
		break;
	case 3:
		Create3(x, y);
		break;
	case 4:
		Create4(x, y);
		break;
	case 5:
		Create5(x, y);
		break;
	case 6:
		Create6(x, y);
		break;
	case 7:
		Create7(x, y);
		break;
	}
	
	UpdateMovement();
}
Ejemplo n.º 5
0
void Window_Base::Update() {
	Window::Update();
	if (Game_System::GetSystemName() != windowskin_name) {
		windowskin_name = Game_System::GetSystemName();
		SetWindowskin(Cache::System(windowskin_name));
	}
	SetStretch(Game_System::GetMessageStretch() == RPG::System::Stretch_stretch);
	UpdateMovement();
}
Ejemplo n.º 6
0
int CObject::Update (void)
{
	short	nPrevSegment = (short) info.nSegment;

#if DBG
if ((info.nType == OBJ_WEAPON) && (info.nId == SMARTMINE_BLOB_ID)) {
	nDbgObj = OBJ_IDX (this);
	nDbgObj = nDbgObj;
	}
if (OBJ_IDX (this) == nDbgObj)
	nDbgObj = nDbgObj;
#endif
if (info.nType == OBJ_ROBOT) {
	if (gameOpts->gameplay.bNoThief && (!IsMultiGame || IsCoopGame) && ROBOTINFO (info.nId).thief) {
		info.xShields = 0;
		info.xLifeLeft = 0;
		Die ();
		}
	else {
		fix xMaxShields = RobotDefaultShields (this);
		if (info.xShields > xMaxShields)
			info.xShields = xMaxShields;
		}
	}
info.vLastPos = info.position.vPos;			// Save the current position
RepairDamage ();
HandleSpecialSegment ();
if ((info.xLifeLeft != IMMORTAL_TIME) &&
	 (info.xLifeLeft != ONE_FRAME_TIME) &&
	 (gameData.physics.xTime != I2X (1)))
	info.xLifeLeft -= (fix) (gameData.physics.xTime / gameStates.gameplay.slowmo [0].fSpeed);		//...inevitable countdown towards death
gameStates.render.bDropAfterburnerBlob = 0;
if ((gameData.physics.xTime != I2X (1)) && UpdateControl ()) {
	UpdateEffects ();
	return 1;
	}
if (info.xLifeLeft < 0) {		// We died of old age
	Die ();
	if ((info.nType == OBJ_WEAPON) && WI_damage_radius (info.nId))
		ExplodeBadassWeapon (info.position.vPos);
	else if (info.nType == OBJ_ROBOT)	//make robots explode
		Explode (0);
	}
if ((info.nType == OBJ_NONE) || (info.nFlags & OF_SHOULD_BE_DEAD)) {
	return 1;			//CObject has been deleted
	}
UpdateMovement ();
UpdateEffects ();
if (CheckTriggerHits (nPrevSegment))
	return 0;
CheckWallPhysics ();
CheckGuidedMissileThroughExit (nPrevSegment);
CheckAfterburnerBlobDrop ();
return 1;
}
void CNetManager::_UnloadMovementUpdate(int* msgNr)
{
	_inMsg->UnloadMessage(*msgNr, &_movementUpdate, frozen::movementUpdateSize);
	log << INFO << "MovementUpdate id: " << _movementUpdate.characterID << endl;
	log << INFO << "MovementUpdate xpos: " << _movementUpdate.xPos << endl;
	log << INFO << "MovementUpdate ypos: " << _movementUpdate.yPos << endl;
	log << INFO << "MovementUpdate xvel: " << _movementUpdate.xVel << endl;
	log << INFO << "MovementUpdate yvel: " << _movementUpdate.yVel << endl;

	UpdateMovement(_movementUpdate.characterID);
}
Ejemplo n.º 8
0
void Missile::Update()
{
	if (!IsActive())
		return;

	GameObject::UpdateComponents();
	
	UpdateMovement();

	//CheckBounds();
}
Ejemplo n.º 9
0
void Particle::Update(float deltaTime)
{
	if (!alive)
		return;
	
	UpdateMovement(deltaTime);

	age += deltaTime;

	if (age > lifespan)
		alive = false;

	*color -= (*colorDecay * deltaTime);
}
Ejemplo n.º 10
0
void Tetronimo::Move(int x, int y)
{
	int i = 0;
	Point p;
	Point vector;
	for(i=0;i<4;i++)
	{
		if(i==0)
		{
			vector = grid->GetPoint(x - squares[i].x,y -  squares[i].y);
		}
		p = grid->GetMovePointVector(grid->GetPoint(squares[i].x, squares[i].y), vector);
		squares[i].x = p.x;
		squares[i].y = p.y;
	}
	UpdateMovement();
}
Ejemplo n.º 11
0
//typedef enum { Up, UpRight, Right, DownRight, Down, DownLeft, Left, UpLeft, None } Direction;
void Ship::PlayerUpdate()
{  
  // Be clever and arrange the enums so you can do a bit mask?
  if ( DPad == UpLeft || DPad == Left || DPad == DownLeft )
  {
    ShipRotation -= RotationRate * DeltaTime;
    ( ShipRotation > 360 ) ? ShipRotation -= 360 : ( ( ShipRotation < 0 ) ? ShipRotation += 360 : ShipRotation );
  }
  else if (DPad == UpRight || DPad == Right || DPad == DownRight )
  {
    ShipRotation += RotationRate * DeltaTime;
    ( ShipRotation > 360 ) ? ShipRotation -= 360 : ( ( ShipRotation < 0 ) ? ShipRotation += 360 : ShipRotation );
  }

  int rotation = ShipRotation / 45;
  ShipFacing = static_cast<Direction>( rotation );
  
  // 28,200 -> 28,138
  PlayerShip->BitMap = PlayerBitMaps[ShipFacing];
  
  // Friction
  if (! ( DPad == Up || DPad == UpRight || DPad == UpLeft ) )
  {
    Vector2d friction = *Velocity;
    friction = friction * -1.0f * ShipFriction * DeltaTime;
    *Velocity += friction;
  }

  Vector2d thrust = Vector2d( 0, 0 );
  if ( DPad == Up || DPad == UpRight || DPad == UpLeft )
    thrust = CalcThrust( ShipFacing );
  else if ( DPad == Down || DPad == DownRight || DPad == DownLeft )
    thrust = CalcThrust( ShipFacing ) * -0.4f;
  
  UpdateMovement( thrust );

  {
    TimeUntilNextRepair -= DeltaTime;
    if ( TimeUntilNextRepair <= 0 )
    {
      TimeUntilNextRepair = RepairTime;// + ( RepairTime * 10 - RepairTime * 10 * Crew / Max_Crew );
      RepairSystem();
    }
  }
}
Ejemplo n.º 12
0
//-------------------------------- Update -------------------------------------
//
void Raven_Bot::Update()
{
  //process the currently active goal. Note this is required even if the bot
  //is under user control. This is because a goal is created whenever a user 
  //clicks on an area of the map that necessitates a path planning request.
  m_pBrain->Process();
  
  //Calculate the steering force and update the bot's velocity and position
  UpdateMovement();

  //if the bot is under AI control but not scripted
  if (!isPossessed())
  {           
    //examine all the opponents in the bots sensory memory and select one
    //to be the current target
    if (m_pTargetSelectionRegulator->isReady())
    {      
      m_pTargSys->Update();
    }

    //appraise and arbitrate between all possible high level goals
    if (m_pGoalArbitrationRegulator->isReady())
    {
       m_pBrain->Arbitrate(); 
    }

    //update the sensory memory with any visual stimulus
    if (m_pVisionUpdateRegulator->isReady())
    {
      m_pSensoryMem->UpdateVision();
    }
  
    //select the appropriate weapon to use from the weapons currently in
    //the inventory
    if (m_pWeaponSelectionRegulator->isReady())
    {       
      m_pWeaponSys->SelectWeapon();       
    }

    //this method aims the bot's current weapon at the current target
    //and takes a shot if a shot is possible
    m_pWeaponSys->TakeAimAndShoot();
  }
}
Ejemplo n.º 13
0
/*
return 0; nista
return 1; random encounter
return 2; creature interaction
*/
int Game::Move(Orientation Direction)
{
    switch(Direction)
    {
    case NORTH:
        Player.InteractsWith = ObjectGrid[Player.GetY()/32-1][Player.GetX()/32];
        break;
    case SOUTH:
        Player.InteractsWith = ObjectGrid[Player.GetY()/32+1][Player.GetX()/32];
        break;
    case EAST:
        Player.InteractsWith = ObjectGrid[Player.GetY()/32][Player.GetX()/32-1];
        break;
    case WEST:
        Player.InteractsWith = ObjectGrid[Player.GetY()/32][Player.GetX()/32+1];
        break;
    }

    if(Player.InteractsWith != NO_OBJECT)
        return 2;

    switch(Direction)
    {
    case NORTH:
        if(CheckPortals(Player.GetX(), Player.GetY()-32))
            return 0;
        if(!UpdateMovement(Player.GetX(), Player.GetY()-32, Direction))
            break;
        Player.SetY(Player.GetY() - 32);
        break;
    case SOUTH:
        if(CheckPortals(Player.GetX(), Player.GetY()+32))
            return 0;
        if(!UpdateMovement(Player.GetX(), Player.GetY()+32, Direction))
            break;
        Player.SetY(Player.GetY() + 32);
        break;
    case WEST:
        if(CheckPortals(Player.GetX()+32, Player.GetY()))
            return 0;
        if(!UpdateMovement(Player.GetX()+32, Player.GetY(), Direction))
            break;
        Player.SetX(Player.GetX() + 32);
        break;
    case EAST:
        if(CheckPortals(Player.GetX()-32, Player.GetY()))
            return 0;
        if(!UpdateMovement(Player.GetX()-32, Player.GetY(), Direction))
            break;
        Player.SetX(Player.GetX() - 32);
        break;
    }

    Player.SetHealth(Player.GetHealth() + 1);
    Player.SetPower(Player.GetPower() + 1);

    if(urand(0, 100) < 15)
       return 1;

    return 0;
}
Ejemplo n.º 14
0
bool Tetronimo::CanMoveToSpawningPosition()
{
	UpdateMovement();
	return canMoveToSpawningPosition;
}
void CAnimatedCharacterSample::OnPrePhysicsUpdate()
{
	UpdateMovement();
	UpdateAnimationGraphState();
}
Ejemplo n.º 16
0
void Player::Update(const long elapsed_time)
{
    UpdateRays(elapsed_time);
    UpdateRotation(elapsed_time);
    UpdateMovement(elapsed_time);
}
Ejemplo n.º 17
0
//Update
void CPlayer::Update(double dt, float CamAngle)
{
	UpdateMovement(dt);
}