danmaku/enemy.cpp

49 lines
1.0 KiB
C++

#include "enemy.h"
// /////////////////////////////////////////////////////////// //
static Textures::Id toTextureID(const Enemy::Type& type)
{
switch (type)
{
case Enemy::Type::Shotguner:
return Textures::Id::Shotguner;
case Enemy::Type::Weakling:
return Textures::Id::Weakling;
case Enemy::Type::Player:
return Textures::Id::Player;
}
return Textures::Id::Weakling;
}
// /////////////////////////////////////////////////////////// //
Enemy::Enemy(Type type, const TextureHolder& texture_holder) :
enemy_type(type),
enemy_sprite(texture_holder.get(toTextureID(type)))
{
const sf::FloatRect bounds = enemy_sprite.getLocalBounds();
enemy_sprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
}
Enemy::~Enemy()
{}
Enemy::Type Enemy::type() const
{
return enemy_type;
}
Category::Type Enemy::category() const
{
return Category::Type::Enemy;
}
void Enemy::drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw(enemy_sprite, states);
}