mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 16:43:05 +02:00
33 lines
855 B
C++
33 lines
855 B
C++
#ifndef AIRCRAFT_CPP
|
|
#define AIRCRAFT_CPP
|
|
|
|
Textures::ID toTextureID(Aircraft::Type type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case Aircraft::Eagle:
|
|
return Textures::Eagle;
|
|
|
|
case Aircraft::Raptor:
|
|
return Textures::Raptor;
|
|
|
|
default:
|
|
return Textures::Eagle;
|
|
}
|
|
return Textures::Eagle;
|
|
}
|
|
|
|
|
|
Aircraft::Aircraft(Type type, const TextureHolder& textures) : mType(type), mSprite(textures.get(toTextureID(type)))
|
|
{
|
|
sf::FloatRect bounds = mSprite.getLocalBounds(); // we get local bounding rectangle which means that we do not take transforms into account, as opposed to getGlobalBounds()
|
|
mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f); // we want to set origin of the sprite to the middle of a rectangle around it
|
|
}
|
|
|
|
void Aircraft::drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const
|
|
{
|
|
target.draw(mSprite, states);
|
|
}
|
|
|
|
#endif
|