Fixed player path finding, made Character::move() private.
This commit is contained in:
parent
0b792295f7
commit
d585a82ada
3 changed files with 9 additions and 8 deletions
|
@ -60,7 +60,7 @@ Character::onDamage(int damage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement this function for any (regular) AI computations.
|
* Implement this function for any (periodical) AI computations.
|
||||||
* If overwritten, this function should always be called from the overwriting function.
|
* If overwritten, this function should always be called from the overwriting function.
|
||||||
*
|
*
|
||||||
* @param elapsed Amount of time to simulate.
|
* @param elapsed Amount of time to simulate.
|
||||||
|
@ -68,6 +68,7 @@ Character::onDamage(int damage) {
|
||||||
void
|
void
|
||||||
Character::onThink(int elapsed) {
|
Character::onThink(int elapsed) {
|
||||||
mWeapon->onThink(elapsed);
|
mWeapon->onThink(elapsed);
|
||||||
|
move();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +128,7 @@ Character::setDestination(const sf::Vector2f& destination) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move towards a destination. Call setDestination() for setting the destination.
|
* Move towards a destination. Call setDestination() for setting the destination.
|
||||||
* This should be called from think() if path finding is to be used.
|
* This is automatically called from onThink().
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Character::move() {
|
Character::move() {
|
||||||
|
|
|
@ -33,11 +33,13 @@ protected:
|
||||||
void pullTrigger();
|
void pullTrigger();
|
||||||
void releaseTrigger();
|
void releaseTrigger();
|
||||||
bool setDestination(const sf::Vector2f& destination);
|
bool setDestination(const sf::Vector2f& destination);
|
||||||
void move();
|
|
||||||
bool isMoving() const;
|
bool isMoving() const;
|
||||||
bool isVisible(const sf::Vector2f& target) const;
|
bool isVisible(const sf::Vector2f& target) const;
|
||||||
std::vector<std::shared_ptr<Character> > getCharacters() const;
|
std::vector<std::shared_ptr<Character> > getCharacters() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void move();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const std::string KEY_HEALTH;
|
static const std::string KEY_HEALTH;
|
||||||
static const int DEFAULT_HEALTH;
|
static const int DEFAULT_HEALTH;
|
||||||
|
|
|
@ -34,9 +34,7 @@ Enemy::onThink(int elapsed) {
|
||||||
setDirection(target->getPosition() - getPosition());
|
setDirection(target->getPosition() - getPosition());
|
||||||
pullTrigger();
|
pullTrigger();
|
||||||
}
|
}
|
||||||
else if (isMoving())
|
else if (!isMoving())
|
||||||
move();
|
|
||||||
else
|
|
||||||
setDestination(target->getPosition());
|
setDestination(target->getPosition());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Reference in a new issue