Created
December 24, 2014 11:36
-
-
Save eXpl0it3r/3f0fe400c3852ab4a370 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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