//--------------------------- Render -------------------------------------
//
//------------------------------------------------------------------------
void Raven_Bot::Render()                                         
{
  //when a bot is hit by a projectile this value is set to a constant user
  //defined value which dictates how long the bot should have a thick red
  //circle drawn around it (to indicate it's been hit) The circle is drawn
  //as long as this value is positive. (see Render)
  m_iNumUpdatesHitPersistant--;


  if (isDead() || isSpawning()) return;
  
  gdi->BluePen();
  
  m_vecBotVBTrans = WorldTransform(m_vecBotVB,
                                   Pos(),
                                   Facing(),
                                   Facing().Perp(),
                                   Scale());

  gdi->ClosedShape(m_vecBotVBTrans);
  
  //draw the head
  (gdi->*(m_pTeam->GetPen()))();
  gdi->Circle(Pos(), 6.0 * Scale().x);


  //render the bot's weapon
  m_pWeaponSys->RenderCurrentWeapon();

  //render a thick red circle if the bot gets hit by a weapon
  if (m_bHit)
  {
    gdi->ThickRedPen();
    gdi->HollowBrush();
    gdi->Circle(m_vPosition, BRadius()+1);

    if (m_iNumUpdatesHitPersistant <= 0)
    {
      m_bHit = false;
    }
  }

  gdi->TransparentText();
  gdi->TextColor(0,255,0);

  if (UserOptions->m_bShowBotIDs)
  {
    gdi->TextAtPos(Pos().x -10, Pos().y-20, ttos(ID()));
  }

  if (UserOptions->m_bShowBotHealth)
  {
    gdi->TextAtPos(Pos().x-40, Pos().y-5, "H:"+ ttos(Health()));
  }

  if (UserOptions->m_bShowScore)
  {
    gdi->TextAtPos(Pos().x-40, Pos().y+10, "Scr:"+ ttos(Score()));
  }    
}
// ------------------------------------------------------------------------------------------------
Uint32 ProjectileBase :: WriteToPacket(Uint32 dataWritePos, Uint8 data[])
{
	Uint32 sendId = Id();
	ProjectileType sendType = Type();
    Vector2df sendPos = Pos();
    Uint32 sendHeadingDeg = HeadingDeg();
    float sendSpeed = Speed();
    Uint32 sendOwnerPlayerId = OwnerPlayerId();
    float sendLife = Life();
    Uint32 sendHealth = Health();
    bool sendIsMoving = IsMoving();

    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_ID], &sendId, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_TYPE], &sendType, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_POSX], &sendPos.x, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_POSY], &sendPos.y, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_HEADING], &sendHeadingDeg, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_SPEED], &sendSpeed, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_LIFE], &sendLife, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_HEALTH], &sendHealth, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_PLAYER_ID], &sendOwnerPlayerId, 4);
	memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_ISMOVING], &sendIsMoving, 1);

    return PACKET_WRITE_PROJECTILE_LENGTH;
} // ----------------------------------------------------------------------------------------------
Beispiel #3
0
void Agent::Update(float a_deltaTime)
{
	// Update the velocity with the current acceleration
	m_movementInfo.m_velocityX += m_movementInfo.m_accelerationX;
	m_movementInfo.m_velocityY += m_movementInfo.m_accelerationY;

	// constrain the velocity
	if (m_movementInfo.m_velocityX > m_movementInfo.m_maxSpeed)
	{
		m_movementInfo.m_velocityX = m_movementInfo.m_maxSpeed;
	}
	else if (m_movementInfo.m_velocityX < -m_movementInfo.m_maxSpeed)
	{
		m_movementInfo.m_velocityX = -m_movementInfo.m_maxSpeed;
	}
	if (m_movementInfo.m_velocityY > m_movementInfo.m_maxSpeed)
	{
		m_movementInfo.m_velocityY = m_movementInfo.m_maxSpeed;
	}
	else if (m_movementInfo.m_velocityY < -m_movementInfo.m_maxSpeed)
	{
		m_movementInfo.m_velocityY = -m_movementInfo.m_maxSpeed;
	}
	
	// set rotation
	m_movementInfo.m_rotation = atan2(m_movementInfo.m_velocityY, m_movementInfo.m_velocityX) + (float)M_PI / 2.0f;

	// reset the acceleration for the next frame
	m_movementInfo.m_accelerationX = 0.0f;
	m_movementInfo.m_accelerationY = 0.0f;

	// add the velocity to the position
	m_movementInfo.m_positionX += m_movementInfo.m_velocityX;
	m_movementInfo.m_positionY += m_movementInfo.m_velocityY;

	CheckCollisions();
	switch (GetColour())
	{
	case Colour::Green: Patrol(); break;
	case Colour::Blue: Health(); break;
	case Colour::Red: Attack(); break;
	case Colour::Orange: Search(); break;
	}
	
}
coment::Entity EntityFactory::createEnemyShip(coment::World& world, std::string name, Sprite::Layer layer, float health, float x, float y, float vx, float vy, float boundsRadius)
{
    coment::Entity entity = world.createEntity();

    world.addComponent<Position>(entity, Position(x, y));

    Sprite sprite;
    sprite.name = name;
    sprite.layer = layer;
    world.addComponent(entity, sprite);

    world.addComponent(entity, Health(health));
    world.addComponent(entity, Enemy());
    world.addComponent(entity, Velocity(vx, vy));
    world.addComponent(entity, Bounds(boundsRadius));

    world.addGroup(entity, "ENEMY_SHIPS");

    return entity;
}
coment::Entity EntityFactory::createPlayer(coment::World& world, float x, float y)
{
    coment::Entity entity = world.createEntity();

    world.addComponent<Position>(entity, Position(x, y));

    Sprite sprite;
    sprite.name = "spaceship";
    sprite.layer = Sprite::Layer::ACTORS_3;

    world.addComponent(entity, sprite);
    world.addComponent(entity, Velocity(0.f, 0.f));
    world.addComponent(entity, Health(10));
    world.addComponent(entity, Bounds(43.f));
    world.addComponent(entity, Player());

    world.addGroup(entity, "PLAYER_SHIP");
    world.setTag(entity, "PLAYER");

    return entity;
}
Beispiel #6
0
void CCar::SWheel::SaveNetState(NET_Packet& P)
{
	CSE_ALifeCar::SWheelState ws;
	ws.health=Health();
	ws.write(P);
}