Skip to content

Instantly share code, notes, and snippets.

@eXpl0it3r
Created December 24, 2014 11:36
Show Gist options
  • Save eXpl0it3r/3f0fe400c3852ab4a370 to your computer and use it in GitHub Desktop.
Save eXpl0it3r/3f0fe400c3852ab4a370 to your computer and use it in GitHub Desktop.
#ifndef ENTITY_HPP
#define ENTITY_HPP
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/Transformable.hpp>
#include <SFML/Graphics/RenderStates.hpp>
// Forward declerations
namespace sf
{
class Texture;
class RenderTarget;
}
class Entity : public sf::Drawable, public sf::Transformable
{
protected:
virtual void draw(sf::RenderTarget& target, RenderStates states) const = 0;
protected:
sf::Sprite m_sprite;
sf::Texture* m_texture;
};
#endif // ENTITY_HPP
#include "Player.hpp"
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
Player::Player(sf::Texture& texture)
: m_texture(texture)
, m_sprite(m_texture)
{
}
void Player::draw(sf::RenderTarget& target, RenderStates states)
{
target.draw(m_sprite);
}
#ifndef PLAYER_HPP
#define PLAYER_HPP
#include "Entity.hpp"
class Player : public Entity
{
public:
Player(sf::Texture& texture);
private:
virtual void draw(sf::RenderTarget& target, RenderStates states) const;
};
#endif // PLAYER_HPP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment