From b360a2a894df03874e09b32409156b84e0d8bbbf Mon Sep 17 00:00:00 2001
From: Rtch90 <ritchie.cunningham@protonmail.com>
Date: Thu, 12 Apr 2012 01:55:07 +0100
Subject: [PATCH 1/2] [Add] Half way through axis aligned bounding box
 implementation.

---
 src/Actor/Player.cpp | 34 +++++++++++++++++++++++++++++-----
 src/Actor/Player.h   | 24 +++++++++++++++++++++++-
 src/Main/Game.cpp    |  4 ++--
 3 files changed, 54 insertions(+), 8 deletions(-)

diff --git a/src/Actor/Player.cpp b/src/Actor/Player.cpp
index d3550ab..35410a8 100644
--- a/src/Actor/Player.cpp
+++ b/src/Actor/Player.cpp
@@ -1,18 +1,38 @@
 #include "Player.h"
 
 Player::Player(void) {
-  PLAYER_SPEED = 15;
-  _rotationAngle = 0.0f;
+  PLAYER_SPEED      = 15;
+  _rotationAngle    = 0.0f;
+  _allowCollision   = true;
+  _notColliding     = false;
+  _blueCollision    = false;
+
+  // Loading of sprites and collision details.
+  _player->LoadSprite("../Data/Img/Player.png");
+  // This should be directed to a collision sheet.
+  _collisionBound = new AABB();
+  _collisionBound->CreateAABBFromSprite("../Data/Img/Player.png");
+
+  _environmentCollisionBound = new AABB();
+  _environmentCollisionBound->SetMin(_collisionBound->GetMin().x, _collisionBound->GetMax().y - 50.0f);
+  _environmentCollisionBound->SetMax(_collisionBound->GetMax());
 }
 
 Player::~Player(void) {
   delete _player;
+  delete _collisionBound;
 }
 
-void Player::Prepare(void) {
-  _player = new Sprite();
+void Player::Update(void) {
+  // Position and collision bound with the player.
+  _collisionBound->SetPositionOffset(_player->GetX(), _player->GetY());
+  _environmentCollisionBound->SetPositionOffset(_player->GetX, _player->GetY());
 
-  _player->LoadSprite("../Data/Img/Player.png");
+  // Time to process the collisions.
+  ProcessCollisions();
+
+  // Process events here.
+  ProcessEvents();
 }
 
 void Player::Render(void) {
@@ -20,6 +40,10 @@ void Player::Render(void) {
   _player->Draw();
 }
 
+void Player::ProcessCollisions(void) {
+
+}
+
 void Player::ProcessEvents(void) {
   x = _player->GetX();
   y = _player->GetY();
diff --git a/src/Actor/Player.h b/src/Actor/Player.h
index 6f53d27..2205162 100644
--- a/src/Actor/Player.h
+++ b/src/Actor/Player.h
@@ -1,5 +1,6 @@
 #pragma once
 #include "../Sprite/Sprite.h"
+#include "../Collision/AABB.h"
 #include "../Global/Globals.h"
 #include "../System/Debug.h"
 #include "../IO/Input.h"
@@ -12,8 +13,21 @@ public:
   Player(void);
   ~Player(void);
 
-  void Prepare(void);
+  void Update(void);
   void Render(void);
+
+  // --- Collision stuff.
+
+  // Process the collisions and reactions.
+  void ProcessCollisions(void);
+  // Entity collision test.
+  void EntityCollisionTest(void);
+  // Actor(NPCS).
+  void ActorCollisionTest(void);
+  AABB* GetAABB(void);
+
+  bool GetInBlueCollision(void);
+
   void ProcessEvents(void);
 
 private:
@@ -22,4 +36,12 @@ private:
   float PLAYER_SPEED;
   Sprite*   _player;
   float     _rotationAngle;
+
+  // --- Collisions.
+  bool _allowCollision;
+  bool _notColliding;
+  bool _blueCollision;
+
+  AABB* _collisionBound;
+  AABB* _environmentCollisionBound;
 };
diff --git a/src/Main/Game.cpp b/src/Main/Game.cpp
index 87a70c9..738a031 100644
--- a/src/Main/Game.cpp
+++ b/src/Main/Game.cpp
@@ -32,7 +32,7 @@ bool Game::Init(void) {
   glAlphaFunc(GL_GREATER, 0.1f);
 
   _level->Load("../Data/Map/Ugly.tmx");
-  _player->Prepare();
+  _player->Update();
 
   // Return success.
   return true;
@@ -64,7 +64,7 @@ void Game::Shutdown(void) {
 }
 
 void Game::ProcessEvents(void) {
-  _player->ProcessEvents();
+  // Should not need this, as the game class has no events to process..
 }
 
 void Game::OnResize(int width, int height) {

From 68251906c934a0e375976110bb90fe84d03eef03 Mon Sep 17 00:00:00 2001
From: Rtch90 <ritchie.cunningham@protonmail.com>
Date: Thu, 12 Apr 2012 02:06:57 +0100
Subject: [PATCH 2/2] [Add] Adding some more collision stuff. Going to finish
 up tomorrow.

---
 src/Actor/Player.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/Actor/Player.cpp b/src/Actor/Player.cpp
index 35410a8..7eaff75 100644
--- a/src/Actor/Player.cpp
+++ b/src/Actor/Player.cpp
@@ -41,7 +41,24 @@ void Player::Render(void) {
 }
 
 void Player::ProcessCollisions(void) {
+  // Process collisions with entities and actors.
+  // We should ensure we are not dead.
+  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.
 }
 
 void Player::ProcessEvents(void) {