diff --git a/source/Game.cpp b/source/Game.cpp index d925ed3..82be4fa 100644 --- a/source/Game.cpp +++ b/source/Game.cpp @@ -57,10 +57,10 @@ Game::generate() { mTileManager.insertTile(TileManager::TilePosition(x, 4), TileManager::Type::WALL); } - mWorld.insert(std::shared_ptr(new Enemy(mWorld, mPathfinder, + mWorld.insert(std::shared_ptr(new Enemy(mWorld, sf::Vector2f(400.0f, 200.0f), Yaml("enemy.yaml")))); - mPlayer = std::shared_ptr(new Player(mWorld, mPathfinder, + mPlayer = std::shared_ptr(new Player(mWorld, sf::Vector2f(200.0f, 100.0f), Yaml("player.yaml"))); mWorld.insert(mPlayer); } diff --git a/source/Game.h b/source/Game.h index f399de7..8905e63 100644 --- a/source/Game.h +++ b/source/Game.h @@ -18,7 +18,6 @@ #include "sprites/TileManager.h" #include "sprites/Player.h" #include "World.h" -#include "util/Pathfinder.h" class Player; class World; @@ -57,7 +56,6 @@ private: World mWorld; TileManager mTileManager; - Pathfinder mPathfinder; std::shared_ptr mPlayer; bool mQuit; diff --git a/source/abstract/Character.cpp b/source/abstract/Character.cpp index fd8d626..551d3d5 100644 --- a/source/abstract/Character.cpp +++ b/source/abstract/Character.cpp @@ -27,11 +27,9 @@ std::vector Character::mCharacterInstances = std::vector /** * Saves pointer to this instance in static var for think(). */ -Character::Character(World& world, Pathfinder& pathfinder, - const Data& data, const Yaml& config) : +Character::Character(World& world, const Data& data, const Yaml& config) : Sprite(data, config), mWorld(world), - mPathfinder(pathfinder), mMaxHealth(config.get(KEY_HEALTH, DEFAULT_HEALTH)), mCurrentHealth(mMaxHealth), mMovementSpeed(config.get(KEY_SPEED, DEFAULT_SPEED)), @@ -129,7 +127,7 @@ Character::releaseTrigger() { */ bool Character::setDestination(const sf::Vector2f& destination) { - mPath = mPathfinder.getPath(*this, destination); + //mPath = mPathfinder.getPath(*this, destination); // Make sure we found a path. if (mPath.empty()) { LOG_I("No path found to destination."); diff --git a/source/abstract/Character.h b/source/abstract/Character.h index c8c44e8..125c7a7 100644 --- a/source/abstract/Character.h +++ b/source/abstract/Character.h @@ -14,14 +14,12 @@ #include "Sprite.h" #include "../World.h" #include "../items/Weapon.h" -#include "../util/Pathfinder.h" #include "../util/Yaml.h" class World; class Weapon; class Instances; class Sprite; -class Pathfinder; class Yaml; /** @@ -30,8 +28,7 @@ class Yaml; class Character : public Sprite { // Public functions. public: - Character(World& world, Pathfinder& pathfinder, - const Data& data, const Yaml& config); + Character(World& world, const Data& data, const Yaml& config); virtual ~Character() = 0; static void think(int elapsed); @@ -62,7 +59,6 @@ private: static std::vector mCharacterInstances; World& mWorld; - Pathfinder& mPathfinder; const int mMaxHealth; int mCurrentHealth; //< Current health. Between 0 and mMaxHealth. diff --git a/source/sprites/Enemy.cpp b/source/sprites/Enemy.cpp index f5e7316..fbe082d 100644 --- a/source/sprites/Enemy.cpp +++ b/source/sprites/Enemy.cpp @@ -9,9 +9,7 @@ #include "Corpse.h" -Enemy::Enemy(World& collection, Pathfinder& pathfinder, - const sf::Vector2f& position, const Yaml& config) : - Character(collection, pathfinder, - Data(position, 0, CATEGORY_ACTOR, MASK_ALL), +Enemy::Enemy(World& collection, const sf::Vector2f& position, const Yaml& config) : + Character(collection, Data(position, 0, CATEGORY_ACTOR, MASK_ALL), config) { } diff --git a/source/sprites/Enemy.h b/source/sprites/Enemy.h index b880b68..0c85b22 100644 --- a/source/sprites/Enemy.h +++ b/source/sprites/Enemy.h @@ -22,8 +22,7 @@ class Yaml; class Enemy : public Character { // Public functions. public: - Enemy(World& collection, Pathfinder& pathfinder, - const sf::Vector2f& position, const Yaml& config); + Enemy(World& collection, const sf::Vector2f& position, const Yaml& config); }; #endif /* DG_ENEMY_H_ */ diff --git a/source/sprites/Player.cpp b/source/sprites/Player.cpp index 1c22e27..87a79d8 100644 --- a/source/sprites/Player.cpp +++ b/source/sprites/Player.cpp @@ -16,10 +16,8 @@ /** * Initializes Sprite. */ -Player::Player(World& world, Pathfinder& pathfinder, - const sf::Vector2f& position, const Yaml& config) : - Character(world, pathfinder, - Data(position, 0, CATEGORY_ACTOR, MASK_ALL), +Player::Player(World& world, const sf::Vector2f& position, const Yaml& config) : + Character(world, Data(position, 0, CATEGORY_ACTOR, MASK_ALL), config), mDirection(0) { } diff --git a/source/sprites/Player.h b/source/sprites/Player.h index 96f7892..5fabe16 100644 --- a/source/sprites/Player.h +++ b/source/sprites/Player.h @@ -13,12 +13,10 @@ #include "../abstract/Character.h" #include "../items/Weapon.h" -#include "../util/Pathfinder.h" #include "../util/Yaml.h" class Character; class Instances; -class Pathfinder; class Weapon; class Yaml; @@ -40,8 +38,7 @@ public: // Public functions. public: - Player(World& world, Pathfinder& pathfinder, - const sf::Vector2f& position, const Yaml& config); + Player(World& world, const sf::Vector2f& position, const Yaml& config); void setCrosshairPosition(const sf::Vector2f& position); void pullTrigger(); diff --git a/source/util/Pathfinder.cpp b/source/util/Pathfinder.cpp deleted file mode 100644 index 485b307..0000000 --- a/source/util/Pathfinder.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Game.cpp - * - * Created on: 24.09.2012 - * Author: Felix - */ - -#include "Pathfinder.h" - - -Pathfinder::Pathfinder() { -} - -std::vector -Pathfinder::getPath(Sprite& physical, const sf::Vector2f& destination) { - return std::vector(); -} diff --git a/source/util/Pathfinder.h b/source/util/Pathfinder.h deleted file mode 100644 index 1375db7..0000000 --- a/source/util/Pathfinder.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * pathfinder.h - * - * Created on: 24.09.2012 - * Author: Felix - */ - -#ifndef PATHFINDER_H_ -#define PATHFINDER_H_ - -#include - -#include "../abstract/Sprite.h" - -class Sprite; - -class Pathfinder { -// Public functions. -public: - Pathfinder(); - - std::vector getPath(Sprite& physical, const sf::Vector2f& destination); -}; - -#endif /* PATHFINDER_H_ */