Merge branch 'master' of github.com:Allanis/LibD
This commit is contained in:
commit
26ad9ed3f8
@ -49,7 +49,8 @@ HEADERS += ../src/Actor/Player.h \
|
|||||||
../src/TMXParser/TmxMap.h \
|
../src/TMXParser/TmxMap.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
|
||||||
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 \
|
||||||
|
@ -14,9 +14,9 @@ Player::Player(void) {
|
|||||||
_collisionBound = new AABB();
|
_collisionBound = new AABB();
|
||||||
_collisionBound->CreateAABBFromSprite("../Data/Img/Player");
|
_collisionBound->CreateAABBFromSprite("../Data/Img/Player");
|
||||||
|
|
||||||
//_environmentCollisionBound = new AABB();
|
_environmentCollisionBound = new AABB();
|
||||||
//_environmentCollisionBound->SetMin(_collisionBound->GetMin().x, _collisionBound->GetMax().y - 50.0f);
|
_environmentCollisionBound->SetMin(_collisionBound->GetMin().x, _collisionBound->GetMax().y - 50.0f);
|
||||||
//_environmentCollisionBound->SetMax(_collisionBound->GetMax());
|
_environmentCollisionBound->SetMax(_collisionBound->GetMax().x, _collisionBound->GetMax().y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player(void) {
|
Player::~Player(void) {
|
||||||
@ -26,11 +26,11 @@ Player::~Player(void) {
|
|||||||
|
|
||||||
void Player::Update(void) {
|
void Player::Update(void) {
|
||||||
// Position and collision bound with the player.
|
// Position and collision bound with the player.
|
||||||
//_collisionBound->SetPositionOffset(_player->GetX(), _player->GetY());
|
_collisionBound->SetPositionOffset(_player->GetX(), _player->GetY());
|
||||||
//_environmentCollisionBound->SetPositionOffset(_player->GetX, _player->GetY());
|
_environmentCollisionBound->SetPositionOffset(_player->GetPosition().x, _player->GetPosition().y);
|
||||||
|
|
||||||
// Time to process the collisions.
|
// Time to process the collisions.
|
||||||
//ProcessCollisions();
|
ProcessCollisions();
|
||||||
|
|
||||||
// Process events here.
|
// Process events here.
|
||||||
ProcessEvents();
|
ProcessEvents();
|
||||||
@ -44,22 +44,15 @@ void Player::Render(void) {
|
|||||||
void Player::ProcessCollisions(void) {
|
void Player::ProcessCollisions(void) {
|
||||||
// Process collisions with entities and actors.
|
// Process collisions with entities and actors.
|
||||||
// We should ensure we are not dead.
|
// We should ensure we are not dead.
|
||||||
//EntityCollisionTest();
|
EntityCollisionTest();
|
||||||
//ActorCollisionTest();
|
ActorCollisionTest();
|
||||||
|
|
||||||
// Set all collision flags to false conditions
|
// Set all collision flags to false conditions
|
||||||
// then they will need to be proven in the test.
|
// then they will need to be proven in the test.
|
||||||
_notColliding = true;
|
_notColliding = true;
|
||||||
_blueCollision = false;
|
_blueCollision = false;
|
||||||
bool onFloor = false;
|
|
||||||
|
|
||||||
// This is going to get messy, and I am going to have to play
|
//if(_environmentCollisionBound->InCollision())
|
||||||
// in KonoM's level stuff.
|
|
||||||
|
|
||||||
// We need a level manager class that will create a list of collidable
|
|
||||||
// entites/actors.
|
|
||||||
|
|
||||||
// I'll do this tomorrow now.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::EntityCollisionTest(void) {
|
void Player::EntityCollisionTest(void) {
|
||||||
@ -91,5 +84,5 @@ void Player::ProcessEvents(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Player::GetWidth() { return _player->GetWidth(); }
|
int Player::GetWidth(void) { return _player->GetWidth(); }
|
||||||
int Player::GetHeight() { return _player->GetWidth(); }
|
int Player::GetHeight(void) { return _player->GetWidth(); }
|
||||||
|
@ -30,10 +30,10 @@ public:
|
|||||||
|
|
||||||
void ProcessEvents(void);
|
void ProcessEvents(void);
|
||||||
|
|
||||||
int GetX() { return x; }
|
int GetX(void) { return x; }
|
||||||
int GetY() { return y; }
|
int GetY(void) { return y; }
|
||||||
int GetWidth();
|
int GetWidth(void);
|
||||||
int GetHeight();
|
int GetHeight(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float x;
|
float x;
|
||||||
|
@ -62,8 +62,8 @@ void AABB::CreateAABBFromSprite(const char* filename) {
|
|||||||
|
|
||||||
// I have no methods here, hopefully KonoM will have it
|
// I have no methods here, hopefully KonoM will have it
|
||||||
// implemented real soon...
|
// implemented real soon...
|
||||||
float spriteWidth = _sprite->w;
|
//float spriteWidth = _sprite->w;
|
||||||
float spriteHeight = _sprite->h;
|
//float spriteHeight = _sprite->h;
|
||||||
|
|
||||||
// Find the min, look through until we find a first instance of a white color.
|
// Find the min, look through until we find a first instance of a white color.
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
25
src/Collision/TileCollision.h
Normal file
25
src/Collision/TileCollision.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../Math/Vec2.h"
|
||||||
|
#include "AABB.h"
|
||||||
|
|
||||||
|
// TileCollision stores collision data loaded from an
|
||||||
|
// an external collision map file. It stores the AABB,
|
||||||
|
// tile ID and chosen color.
|
||||||
|
|
||||||
|
class TileCollision {
|
||||||
|
public:
|
||||||
|
TileCollision(void) {}
|
||||||
|
~TileCollision(void) {}
|
||||||
|
|
||||||
|
void SetAABB(AABB* aabb) { _AABB.SetMax(aabb->GetMax()); _AABB.SetMin(aabb->GetMin()); }
|
||||||
|
void SetAABB(Vec2 &min, Vec2 &max) { _AABB.SetMax(max); _AABB.SetMin(min); }
|
||||||
|
AABB* GetAABB(void) { return &_AABB; }
|
||||||
|
void SetTileNumber(int tileID) { _tileID = tileID; }
|
||||||
|
int SetColor(int color) { _color = color; }
|
||||||
|
int GetColor(void) { return _color; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _tileID;
|
||||||
|
int _color;
|
||||||
|
AABB _AABB;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user