Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Player class
- Player::Player(float x, float y, sf::Texture* texture)
- {
- //ctor
- this->initVariables();
- this->initComponents();
- this->createSprite(texture);
- this->setPosition(x, y);
- }
- Player::~Player()
- {
- //dtor
- }
- void Player::initComponents()
- {
- }
- void Player::initVariables()
- {
- }
- ======================================================
- //Entity class -- the sprite is created here and so the movement function.
- #include "Entity.h"
- Entity::Entity()
- {
- //ctor
- void initVariables();
- //void createSprite();
- }
- Entity::~Entity()
- {
- //dtor
- delete this->sprite;
- }
- void Entity::initVariables()
- {
- this->sprite = NULL;
- this->movementSpeed = 100.f;
- }
- void Entity::createSprite(sf::Texture* texture)
- {
- this->texture = texture;
- this->sprite = new sf::Sprite(*this->texture);
- }
- void Entity::setPosition(const float x, const float y)
- {
- if(this->sprite)
- {
- this->sprite->setPosition(x, y);
- }
- }
- void Entity::update(const float& dt)
- {
- }
- void Entity::render(sf::RenderTarget * target)
- {
- target->draw(*this->sprite);
- }
- void Entity::movement(const float& dt, const float dir_x, const float dir_y)
- {
- this->sprite->move(dir_x * this->movementSpeed *dt, dir_y * this->movementSpeed*dt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement