Merge branch 'master' of github.com:Allanis/LibD

This commit is contained in:
Tamir Atias 2012-04-12 19:12:34 +03:00
commit 26ad9ed3f8
5 changed files with 44 additions and 25 deletions

View File

@ -49,7 +49,8 @@ HEADERS += ../src/Actor/Player.h \
../src/TMXParser/TmxMap.h \
../src/TMXParser/TmxLayer.h \
../src/TMXParser/Tmx.h \
../src/TMXParser/base64.h
../src/TMXParser/base64.h \
../src/Collision/TileCollision.h
SOURCES += ../src/Actor/Player.cpp \
../src/Collision/AABB.cpp \
../src/Global/Globals.cpp \

View File

@ -14,9 +14,9 @@ Player::Player(void) {
_collisionBound = new AABB();
_collisionBound->CreateAABBFromSprite("../Data/Img/Player");
//_environmentCollisionBound = new AABB();
//_environmentCollisionBound->SetMin(_collisionBound->GetMin().x, _collisionBound->GetMax().y - 50.0f);
//_environmentCollisionBound->SetMax(_collisionBound->GetMax());
_environmentCollisionBound = new AABB();
_environmentCollisionBound->SetMin(_collisionBound->GetMin().x, _collisionBound->GetMax().y - 50.0f);
_environmentCollisionBound->SetMax(_collisionBound->GetMax().x, _collisionBound->GetMax().y);
}
Player::~Player(void) {
@ -26,11 +26,11 @@ Player::~Player(void) {
void Player::Update(void) {
// Position and collision bound with the player.
//_collisionBound->SetPositionOffset(_player->GetX(), _player->GetY());
//_environmentCollisionBound->SetPositionOffset(_player->GetX, _player->GetY());
_collisionBound->SetPositionOffset(_player->GetX(), _player->GetY());
_environmentCollisionBound->SetPositionOffset(_player->GetPosition().x, _player->GetPosition().y);
// Time to process the collisions.
//ProcessCollisions();
ProcessCollisions();
// Process events here.
ProcessEvents();
@ -44,22 +44,15 @@ void Player::Render(void) {
void Player::ProcessCollisions(void) {
// Process collisions with entities and actors.
// We should ensure we are not dead.
//EntityCollisionTest();
//ActorCollisionTest();
EntityCollisionTest();
ActorCollisionTest();
// Set all collision flags to false conditions
// then they will need to be proven in the test.
_notColliding = true;
_blueCollision = false;
bool onFloor = false;
// This is going to get messy, and I am going to have to play
// 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.
//if(_environmentCollisionBound->InCollision())
}
void Player::EntityCollisionTest(void) {
@ -91,5 +84,5 @@ void Player::ProcessEvents(void) {
}
}
int Player::GetWidth() { return _player->GetWidth(); }
int Player::GetHeight() { return _player->GetWidth(); }
int Player::GetWidth(void) { return _player->GetWidth(); }
int Player::GetHeight(void) { return _player->GetWidth(); }

View File

@ -30,10 +30,10 @@ public:
void ProcessEvents(void);
int GetX() { return x; }
int GetY() { return y; }
int GetWidth();
int GetHeight();
int GetX(void) { return x; }
int GetY(void) { return y; }
int GetWidth(void);
int GetHeight(void);
private:
float x;

View File

@ -62,8 +62,8 @@ void AABB::CreateAABBFromSprite(const char* filename) {
// I have no methods here, hopefully KonoM will have it
// implemented real soon...
float spriteWidth = _sprite->w;
float spriteHeight = _sprite->h;
//float spriteWidth = _sprite->w;
//float spriteHeight = _sprite->h;
// Find the min, look through until we find a first instance of a white color.
bool found = false;

View 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;
};