Game Development Reference
In-Depth Information
While we're here, let's take a look at the rest of the methods inside Ship .
void Ship::MoveTo(float x, float y)
{
_position.x = x;
_position.y = y;
_sprite->Position = _position;
}
void Ship::Damage(int amount)
{
_health -= amount;
if (_health <= 0)
SetIsAlive(false);
}
bool Ship::GetIsAlive()
{
return _isAlive;
}
void Ship::SetIsAlive(bool value)
{
_isAlive = value;
_sprite->Visible = value;
}
void Ship::Reset()
{
_health = Health;
SetIsAlive(true);
}
Starting from the top, MoveTo allows us to specify an absolute position and jump the
ship there, including the Sprite . This will be useful when we spawn the enemies,
as we need to position them in the right place.
Search WWH ::




Custom Search