[Add] Getting to work on pathfinding, my last one was not complete.

[Fix] Fixed .gitignore
This commit is contained in:
Rtch90 2012-02-01 23:44:04 +00:00
parent 3e01f285e4
commit a3ec190f61
5 changed files with 65 additions and 19 deletions

3
.gitignore vendored
View File

@ -9,10 +9,11 @@ Win32/Unuk/Unuk/Release
Win32/Unuk/Unuk/*.user Win32/Unuk/Unuk/*.user
Win32/Unuk/Unuk.ncb Win32/Unuk/Unuk.ncb
Win32/Unuk/Unuk.suo Win32/Unuk/Unuk.suo
Bin/Unuk
Bin/*.dll Bin/*.dll
*.swp *.swp
*.o *.o
*.exe *.exe
*.log *.log
*Unuk-QT *Unuk-QT
*Unuk

View File

@ -41,7 +41,8 @@ HEADERS += ../src/Libs/wglext.h \
../src/libUnuk/UI/EventHistory.h \ ../src/libUnuk/UI/EventHistory.h \
../src/libUnuk/UI/Bar.h \ ../src/libUnuk/UI/Bar.h \
../src/libUnuk/System/Vec2.h \ ../src/libUnuk/System/Vec2.h \
../src/libUnuk/System/MathBox.h ../src/libUnuk/System/MathBox.h \
../src/libUnuk/Engine/Pathfinding.h
SOURCES += ../src/libUnuk/Engine/WorldManager.cpp \ SOURCES += ../src/libUnuk/Engine/WorldManager.cpp \
../src/libUnuk/Engine/ParticleEmitter.cpp \ ../src/libUnuk/Engine/ParticleEmitter.cpp \
../src/libUnuk/Engine/NPC.cpp \ ../src/libUnuk/Engine/NPC.cpp \
@ -73,5 +74,6 @@ SOURCES += ../src/libUnuk/Engine/WorldManager.cpp \
../src/libUnuk/LevelGen/MapElement.cpp \ ../src/libUnuk/LevelGen/MapElement.cpp \
../src/libUnuk/UI/EventHistory.cpp \ ../src/libUnuk/UI/EventHistory.cpp \
../src/libUnuk/UI/Bar.cpp \ ../src/libUnuk/UI/Bar.cpp \
../src/libUnuk/System/Vec2.cpp ../src/libUnuk/System/Vec2.cpp \
../src/libUnuk/Engine/Pathfinding.cpp
OTHER_FILES += OTHER_FILES +=

View File

@ -1,26 +1,25 @@
#pragma once #pragma once
#include "Character.h" #include "Character.h"
#include "AStar.h"
class NPC : public Character { class NPC : public Character {
public: public:
NPC(LevelGen* mapArg); NPC(LevelGen* mapArg);
~NPC(void); ~NPC(void);
void Update(void); void Update(void);
protected: protected:
void Move(void); void Move(void);
private: private:
int _moveChangeFrequency; int _moveChangeFrequency;
int _moveDurationCurrent; int _moveDurationCurrent;
int _moveDurationMin; int _moveDurationMin;
int _moveDurationMax; int _moveDurationMax;
bool _moving; bool _moving;
Timer _moveTimer; Timer _moveTimer;
}; };

View File

@ -0,0 +1 @@
#include "Pathfinding.h"

View File

@ -0,0 +1,43 @@
#pragma once
#include <iostream>
#include <stdio.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
// Disable warning that debugging information has lines that are truncated.
#ifdef WIN32
#pragma warning(disable : 4786)
#endif
// The search class. UserState is the users state space type.
template<class UserState> class AStarSearch {
public:
enum {
SEARCH_STATE_NOT_INITIALISED,
SEARCH_STATE_SEARCHING,
SEARCH_STATE_SUCCEEDED,
SEARCH_STATE_FAILED,
SEARCH_STATE_OUT_OF_MEMORY,
SEARCH_STATE_INVALID
};
// A node representing a possible state in the search.
class Node {
public:
// Keep a record of successor nodes.
Node* parent;
// Used to view the search in reverse at the end.
Node* child;
float g; // Cost of this and it's predecessors.
float h; // Heuristic estimate of the distance of the goal.
float f; // Sum of cost and heuristic.
Node(void) : parent(0), child(0), g(0.0f), h(0.0f), f(0.0) {}
UserState _UserState;
};
};