コード例 #1
0
ファイル: EscortDisplay.cpp プロジェクト: Expack3/endless-sky
EscortDisplay::Icon::Icon(const Ship &ship, bool isHere)
	: sprite(ship.GetSprite().GetSprite()),
	isHere(isHere && !ship.IsDisabled()),
	stackSize(1),
	cost(ship.Cost()),
	system((!isHere && ship.GetSystem()) ? ship.GetSystem()->Name() : ""),
	low{ship.Shields(), ship.Hull(), ship.Energy(), ship.Heat(), ship.Fuel()},
	high(low)
{
}
コード例 #2
0
ファイル: Projectile.cpp プロジェクト: Phezzan/endless-sky
// Check if this projectile collides with the given step, with the animation
// frame for the given step.
double Projectile::CheckCollision(const Ship &ship, int step) const
{
	const Mask &mask = ship.GetSprite().GetMask(step);
	Point offset = position - ship.Position();
	
	double radius = weapon->TriggerRadius();
	if(radius > 0. && mask.WithinRange(offset, angle, radius))
		return 0.;
	
	return mask.Collide(offset, velocity, ship.Facing());
}
コード例 #3
0
ファイル: ShopPanel.cpp プロジェクト: AMDmi3/endless-sky
void ShopPanel::DrawShip(const Ship &ship, const Point &center, bool isSelected) const
{
	const Sprite *sprite = ship.GetSprite().GetSprite();
	const Sprite *back = SpriteSet::Get(
		isSelected ? "ui/shipyard selected" : "ui/shipyard unselected");
	SpriteShader::Draw(back, center);
	// Make sure the ship sprite leaves 10 pixels padding all around.
	float zoomSize = SHIP_SIZE - 60.f;
	
	// Draw the ship name.
	const string &name = ship.Name().empty() ? ship.ModelName() : ship.Name();
	const Font &font = FontSet::Get(14);
	Point offset(-.5f * font.Width(name), -.5f * SHIP_SIZE + 10.f);
	font.Draw(name, center + offset, *GameData::Colors().Get("bright"));
	
	float zoom = min(1.f, zoomSize / max(sprite->Width(), sprite->Height()));
	int swizzle = GameData::PlayerGovernment()->GetSwizzle();
	
	SpriteShader::Draw(sprite, center, zoom, swizzle);
}
コード例 #4
0
ファイル: Projectile.cpp プロジェクト: Phezzan/endless-sky
// Check if the given ship is within this projectile's blast radius. (The
// projectile will not explode unless it is also within the trigger radius.)
bool Projectile::InBlastRadius(const Ship &ship, int step) const
{
	const Mask &mask = ship.GetSprite().GetMask(step);
	return mask.WithinRange(position - ship.Position(), ship.Facing(), weapon->BlastRadius());
}