diff --git a/source/abstract/Character.cpp b/source/abstract/Character.cpp index c10b100..6d50e7e 100644 --- a/source/abstract/Character.cpp +++ b/source/abstract/Character.cpp @@ -15,10 +15,11 @@ std::vector Character::mInstances = std::vector(); /** * Saves pointer to this instance in static var for think(). */ -Character::Character(int health) : - mMaxHealth(health), - mCurrentHealth(health) { - mInstances.push_back(this); +Character::Character(const sf::String& texturePath, const PhysicalData& data, int health) : + Sprite(texturePath, data), + mMaxHealth(health), + mCurrentHealth(health) { + mInstances.push_back(this); } /** diff --git a/source/abstract/Character.h b/source/abstract/Character.h index c898f02..dbdaab6 100644 --- a/source/abstract/Character.h +++ b/source/abstract/Character.h @@ -10,13 +10,17 @@ #include +#include "Sprite.h" + +class Sprite; + /** * Provides think function for AI. */ -class Character { +class Character : public Sprite { // Public functions. public: - Character(int health); + Character(const sf::String& texturePath, const PhysicalData& data, int health); virtual ~Character() = 0; static void think(float elapsedTime); diff --git a/source/sprite/Enemy.cpp b/source/sprite/Enemy.cpp index 102730e..1015c6c 100644 --- a/source/sprite/Enemy.cpp +++ b/source/sprite/Enemy.cpp @@ -10,9 +10,8 @@ #include "Body.h" Enemy::Enemy(b2World& world, const Vector2f& position, Collection& collection) : - Sprite("enemy.png", PhysicalData(position, Vector2i(50, 50), world, - CATEGORY_ACTOR, MASK_ALL, true, false, true)), - Character(100), + Character("enemy.png", PhysicalData(position, Vector2i(50, 50), world, + CATEGORY_ACTOR, MASK_ALL, true, false, true), 100), mWorld(world), mCollection(collection) { diff --git a/source/sprite/Enemy.h b/source/sprite/Enemy.h index 2e40c0a..ed98562 100644 --- a/source/sprite/Enemy.h +++ b/source/sprite/Enemy.h @@ -9,15 +9,13 @@ #define DG_ENEMY_H #include "../abstract/Character.h" -#include "../abstract/Sprite.h" #include "../util/Collection.h" #include "../util/Vector.h" class Character; -class Sprite; class Collection; -class Enemy : public Sprite, public Character { +class Enemy : public Character { // Public functions. public: Enemy(b2World& world, const Vector2f& position, Collection& collection); diff --git a/source/sprite/Player.cpp b/source/sprite/Player.cpp index 59cfedd..93fd7f4 100644 --- a/source/sprite/Player.cpp +++ b/source/sprite/Player.cpp @@ -21,9 +21,8 @@ const float Player::POINT_REACHED_DISTANCE = 1.0f; */ Player::Player(b2World& world, Collection& collection, const Vector2f& position, Pathfinder& pathfinder) : - Sprite("player.png", PhysicalData(position, SIZE, world, - CATEGORY_ACTOR, MASK_ALL, true, false, true)), - Character(100), + Character("player.png", PhysicalData(position, SIZE, world, + CATEGORY_ACTOR, MASK_ALL, true, false, true), 100), mWeapon(*this, collection, world, SIZE), mDirection(0), mPathfinder(pathfinder) { diff --git a/source/sprite/Player.h b/source/sprite/Player.h index 05b1092..aafef6f 100644 --- a/source/sprite/Player.h +++ b/source/sprite/Player.h @@ -13,19 +13,17 @@ #include "../Pathfinder.h" #include "../abstract/Character.h" -#include "../abstract/Sprite.h" #include "../items/Weapon.h" #include "../util/Vector.h" class Character; class Pathfinder; -class Sprite; class Weapon; /** * Player object. */ -class Player : public Sprite, public Character { +class Player : public Character { // Public types. public: /**