[Add] Adding more collision crap.

[Add] Adding an NPC entitity.
This commit is contained in:
Rtch90 2012-04-12 17:45:17 +01:00
parent 26ad9ed3f8
commit f2d6345a61
7 changed files with 67 additions and 4 deletions

View File

@ -5,7 +5,8 @@ LIBS += -lGL \
-ltinyxml \ -ltinyxml \
-lGLU \ -lGLU \
-lz \ -lz \
-ltinyxml -ltinyxml \
-lSDL_mixer
win32: { win32: {
LIBS -= -lGL \ LIBS -= -lGL \
-lGLU -lGLU
@ -13,7 +14,8 @@ win32: {
-luser32 \ -luser32 \
-lgdi32 \ -lgdi32 \
-lopengl32 \ -lopengl32 \
-lglu32 -lglu32 \
-lSDL_mixer
} }
HEADERS += ../src/Actor/Player.h \ HEADERS += ../src/Actor/Player.h \
../src/Collision/AABB.h \ ../src/Collision/AABB.h \
@ -50,7 +52,8 @@ HEADERS += ../src/Actor/Player.h \
../src/TMXParser/TmxLayer.h \ ../src/TMXParser/TmxLayer.h \
../src/TMXParser/Tmx.h \ ../src/TMXParser/Tmx.h \
../src/TMXParser/base64.h \ ../src/TMXParser/base64.h \
../src/Collision/TileCollision.h ../src/Collision/TileCollision.h \
../src/Actor/NPC.h
SOURCES += ../src/Actor/Player.cpp \ SOURCES += ../src/Actor/Player.cpp \
../src/Collision/AABB.cpp \ ../src/Collision/AABB.cpp \
../src/Global/Globals.cpp \ ../src/Global/Globals.cpp \
@ -79,4 +82,6 @@ SOURCES += ../src/Actor/Player.cpp \
../src/TMXParser/TmxMap.cpp \ ../src/TMXParser/TmxMap.cpp \
../src/TMXParser/TmxLayer.cpp \ ../src/TMXParser/TmxLayer.cpp \
../src/TMXParser/TmxImage.cpp \ ../src/TMXParser/TmxImage.cpp \
../src/TMXParser/base64.cpp ../src/TMXParser/base64.cpp \
../src/Actor/NPC.cpp
OTHER_FILES +=

17
src/Actor/NPC.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "NPC.h"
NPC::NPC(void) {
_NPC->CreateAABBFromSprite("../Data/Img/Player");
}
NPC::~NPC(void) {
delete _NPC;
}
void NPC::Update(void) {
}
void NPC::Render(void) {
//_NPC->
}

14
src/Actor/NPC.h Normal file
View File

@ -0,0 +1,14 @@
#pragma once
#include "../Collision/AABB.h"
class NPC {
public:
NPC(void);
~NPC(void);
void Update(void);
void Render(void);
private:
AABB* _NPC;
};

View File

@ -63,6 +63,10 @@ void Player::ActorCollisionTest(void) {
} }
bool Player::GetInBlueCollision(void) {
return(_blueCollision && _preventMovement != NONE);
}
void Player::ProcessEvents(void) { void Player::ProcessEvents(void) {
x = _player->GetX(); x = _player->GetX();
y = _player->GetY(); y = _player->GetY();

View File

@ -10,6 +10,21 @@ class Sprite;
// We will derive from an Actor class at some point. // We will derive from an Actor class at some point.
class Player { class Player {
public: public:
// Facing enum controls which spritr to render.
enum Facing {
LEFT,
RIGHT,
NONE
};
// Control the current state the character is in.
enum Status {
STANDING = 0,
WALKING,
HURT,
DEAD,
};
Player(void); Player(void);
~Player(void); ~Player(void);
@ -47,6 +62,8 @@ private:
bool _notColliding; bool _notColliding;
bool _blueCollision; bool _blueCollision;
Facing _preventMovement;
AABB* _collisionBound; AABB* _collisionBound;
AABB* _environmentCollisionBound; AABB* _environmentCollisionBound;
}; };

View File

@ -113,3 +113,7 @@ void AABB::CreateAABBFromSprite(const char* filename) {
delete _sprite; delete _sprite;
_sprite = 0; _sprite = 0;
} }
void AABB::Render(void) {
// FUCK YOU KonoM!!
}

View File

@ -33,6 +33,8 @@ public:
bool InCollision(AABB* otherAABB); bool InCollision(AABB* otherAABB);
void CreateAABBFromSprite(const char* filename); void CreateAABBFromSprite(const char* filename);
void Render(void);
private: private:
Vec2 _min; Vec2 _min;
Vec2 _max; Vec2 _max;