[Add] Getting to work on pathfinding, my last one was not complete.
[Fix] Fixed .gitignore
This commit is contained in:
parent
3e01f285e4
commit
a3ec190f61
3
.gitignore
vendored
3
.gitignore
vendored
@ -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
|
|
||||||
|
@ -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 +=
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
1
src/libUnuk/Engine/Pathfinding.cpp
Normal file
1
src/libUnuk/Engine/Pathfinding.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "Pathfinding.h"
|
43
src/libUnuk/Engine/Pathfinding.h
Normal file
43
src/libUnuk/Engine/Pathfinding.h
Normal 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;
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user