Removed Pathfinder class.
This commit is contained in:
parent
394ebc04c7
commit
1dfd878a20
10 changed files with 11 additions and 69 deletions
|
@ -57,10 +57,10 @@ Game::generate() {
|
||||||
mTileManager.insertTile(TileManager::TilePosition(x, 4), TileManager::Type::WALL);
|
mTileManager.insertTile(TileManager::TilePosition(x, 4), TileManager::Type::WALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
mWorld.insert(std::shared_ptr<Sprite>(new Enemy(mWorld, mPathfinder,
|
mWorld.insert(std::shared_ptr<Sprite>(new Enemy(mWorld,
|
||||||
sf::Vector2f(400.0f, 200.0f), Yaml("enemy.yaml"))));
|
sf::Vector2f(400.0f, 200.0f), Yaml("enemy.yaml"))));
|
||||||
|
|
||||||
mPlayer = std::shared_ptr<Player>(new Player(mWorld, mPathfinder,
|
mPlayer = std::shared_ptr<Player>(new Player(mWorld,
|
||||||
sf::Vector2f(200.0f, 100.0f), Yaml("player.yaml")));
|
sf::Vector2f(200.0f, 100.0f), Yaml("player.yaml")));
|
||||||
mWorld.insert(mPlayer);
|
mWorld.insert(mPlayer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "sprites/TileManager.h"
|
#include "sprites/TileManager.h"
|
||||||
#include "sprites/Player.h"
|
#include "sprites/Player.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "util/Pathfinder.h"
|
|
||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
class World;
|
class World;
|
||||||
|
@ -57,7 +56,6 @@ private:
|
||||||
|
|
||||||
World mWorld;
|
World mWorld;
|
||||||
TileManager mTileManager;
|
TileManager mTileManager;
|
||||||
Pathfinder mPathfinder;
|
|
||||||
std::shared_ptr<Player> mPlayer;
|
std::shared_ptr<Player> mPlayer;
|
||||||
|
|
||||||
bool mQuit;
|
bool mQuit;
|
||||||
|
|
|
@ -27,11 +27,9 @@ std::vector<Character*> Character::mCharacterInstances = std::vector<Character*>
|
||||||
/**
|
/**
|
||||||
* Saves pointer to this instance in static var for think().
|
* Saves pointer to this instance in static var for think().
|
||||||
*/
|
*/
|
||||||
Character::Character(World& world, Pathfinder& pathfinder,
|
Character::Character(World& world, const Data& data, const Yaml& config) :
|
||||||
const Data& data, const Yaml& config) :
|
|
||||||
Sprite(data, config),
|
Sprite(data, config),
|
||||||
mWorld(world),
|
mWorld(world),
|
||||||
mPathfinder(pathfinder),
|
|
||||||
mMaxHealth(config.get(KEY_HEALTH, DEFAULT_HEALTH)),
|
mMaxHealth(config.get(KEY_HEALTH, DEFAULT_HEALTH)),
|
||||||
mCurrentHealth(mMaxHealth),
|
mCurrentHealth(mMaxHealth),
|
||||||
mMovementSpeed(config.get(KEY_SPEED, DEFAULT_SPEED)),
|
mMovementSpeed(config.get(KEY_SPEED, DEFAULT_SPEED)),
|
||||||
|
@ -129,7 +127,7 @@ Character::releaseTrigger() {
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
Character::setDestination(const sf::Vector2f& destination) {
|
Character::setDestination(const sf::Vector2f& destination) {
|
||||||
mPath = mPathfinder.getPath(*this, destination);
|
//mPath = mPathfinder.getPath(*this, destination);
|
||||||
// Make sure we found a path.
|
// Make sure we found a path.
|
||||||
if (mPath.empty()) {
|
if (mPath.empty()) {
|
||||||
LOG_I("No path found to destination.");
|
LOG_I("No path found to destination.");
|
||||||
|
|
|
@ -14,14 +14,12 @@
|
||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../items/Weapon.h"
|
#include "../items/Weapon.h"
|
||||||
#include "../util/Pathfinder.h"
|
|
||||||
#include "../util/Yaml.h"
|
#include "../util/Yaml.h"
|
||||||
|
|
||||||
class World;
|
class World;
|
||||||
class Weapon;
|
class Weapon;
|
||||||
class Instances;
|
class Instances;
|
||||||
class Sprite;
|
class Sprite;
|
||||||
class Pathfinder;
|
|
||||||
class Yaml;
|
class Yaml;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,8 +28,7 @@ class Yaml;
|
||||||
class Character : public Sprite {
|
class Character : public Sprite {
|
||||||
// Public functions.
|
// Public functions.
|
||||||
public:
|
public:
|
||||||
Character(World& world, Pathfinder& pathfinder,
|
Character(World& world, const Data& data, const Yaml& config);
|
||||||
const Data& data, const Yaml& config);
|
|
||||||
virtual ~Character() = 0;
|
virtual ~Character() = 0;
|
||||||
|
|
||||||
static void think(int elapsed);
|
static void think(int elapsed);
|
||||||
|
@ -62,7 +59,6 @@ private:
|
||||||
static std::vector<Character*> mCharacterInstances;
|
static std::vector<Character*> mCharacterInstances;
|
||||||
|
|
||||||
World& mWorld;
|
World& mWorld;
|
||||||
Pathfinder& mPathfinder;
|
|
||||||
|
|
||||||
const int mMaxHealth;
|
const int mMaxHealth;
|
||||||
int mCurrentHealth; //< Current health. Between 0 and mMaxHealth.
|
int mCurrentHealth; //< Current health. Between 0 and mMaxHealth.
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
|
|
||||||
#include "Corpse.h"
|
#include "Corpse.h"
|
||||||
|
|
||||||
Enemy::Enemy(World& collection, Pathfinder& pathfinder,
|
Enemy::Enemy(World& collection, const sf::Vector2f& position, const Yaml& config) :
|
||||||
const sf::Vector2f& position, const Yaml& config) :
|
Character(collection, Data(position, 0, CATEGORY_ACTOR, MASK_ALL),
|
||||||
Character(collection, pathfinder,
|
|
||||||
Data(position, 0, CATEGORY_ACTOR, MASK_ALL),
|
|
||||||
config) {
|
config) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,7 @@ class Yaml;
|
||||||
class Enemy : public Character {
|
class Enemy : public Character {
|
||||||
// Public functions.
|
// Public functions.
|
||||||
public:
|
public:
|
||||||
Enemy(World& collection, Pathfinder& pathfinder,
|
Enemy(World& collection, const sf::Vector2f& position, const Yaml& config);
|
||||||
const sf::Vector2f& position, const Yaml& config);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DG_ENEMY_H_ */
|
#endif /* DG_ENEMY_H_ */
|
||||||
|
|
|
@ -16,10 +16,8 @@
|
||||||
/**
|
/**
|
||||||
* Initializes Sprite.
|
* Initializes Sprite.
|
||||||
*/
|
*/
|
||||||
Player::Player(World& world, Pathfinder& pathfinder,
|
Player::Player(World& world, const sf::Vector2f& position, const Yaml& config) :
|
||||||
const sf::Vector2f& position, const Yaml& config) :
|
Character(world, Data(position, 0, CATEGORY_ACTOR, MASK_ALL),
|
||||||
Character(world, pathfinder,
|
|
||||||
Data(position, 0, CATEGORY_ACTOR, MASK_ALL),
|
|
||||||
config),
|
config),
|
||||||
mDirection(0) {
|
mDirection(0) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,10 @@
|
||||||
|
|
||||||
#include "../abstract/Character.h"
|
#include "../abstract/Character.h"
|
||||||
#include "../items/Weapon.h"
|
#include "../items/Weapon.h"
|
||||||
#include "../util/Pathfinder.h"
|
|
||||||
#include "../util/Yaml.h"
|
#include "../util/Yaml.h"
|
||||||
|
|
||||||
class Character;
|
class Character;
|
||||||
class Instances;
|
class Instances;
|
||||||
class Pathfinder;
|
|
||||||
class Weapon;
|
class Weapon;
|
||||||
class Yaml;
|
class Yaml;
|
||||||
|
|
||||||
|
@ -40,8 +38,7 @@ public:
|
||||||
|
|
||||||
// Public functions.
|
// Public functions.
|
||||||
public:
|
public:
|
||||||
Player(World& world, Pathfinder& pathfinder,
|
Player(World& world, const sf::Vector2f& position, const Yaml& config);
|
||||||
const sf::Vector2f& position, const Yaml& config);
|
|
||||||
|
|
||||||
void setCrosshairPosition(const sf::Vector2f& position);
|
void setCrosshairPosition(const sf::Vector2f& position);
|
||||||
void pullTrigger();
|
void pullTrigger();
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* Game.cpp
|
|
||||||
*
|
|
||||||
* Created on: 24.09.2012
|
|
||||||
* Author: Felix
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Pathfinder.h"
|
|
||||||
|
|
||||||
|
|
||||||
Pathfinder::Pathfinder() {
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<sf::Vector2f>
|
|
||||||
Pathfinder::getPath(Sprite& physical, const sf::Vector2f& destination) {
|
|
||||||
return std::vector<sf::Vector2f>();
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
/*
|
|
||||||
* pathfinder.h
|
|
||||||
*
|
|
||||||
* Created on: 24.09.2012
|
|
||||||
* Author: Felix
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PATHFINDER_H_
|
|
||||||
#define PATHFINDER_H_
|
|
||||||
|
|
||||||
#include <SFML/System.hpp>
|
|
||||||
|
|
||||||
#include "../abstract/Sprite.h"
|
|
||||||
|
|
||||||
class Sprite;
|
|
||||||
|
|
||||||
class Pathfinder {
|
|
||||||
// Public functions.
|
|
||||||
public:
|
|
||||||
Pathfinder();
|
|
||||||
|
|
||||||
std::vector<sf::Vector2f> getPath(Sprite& physical, const sf::Vector2f& destination);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* PATHFINDER_H_ */
|
|
Reference in a new issue