From 84bfde227a05f881ff038fa40f4635a2cc3fa931 Mon Sep 17 00:00:00 2001 From: Rtch90 Date: Thu, 12 Apr 2012 18:32:45 +0100 Subject: [PATCH] [Remove] Removed AABB's for now. [Add] Adding some NPC class stuff. Going to work on Actors now. --- src/Actor/NPC.cpp | 4 ++-- src/Actor/NPC.h | 4 ++-- src/Actor/Player.cpp | 48 +------------------------------------------- src/Actor/Player.h | 19 ------------------ src/Main/Game.cpp | 5 ++++- src/Main/Game.h | 4 +++- 6 files changed, 12 insertions(+), 72 deletions(-) diff --git a/src/Actor/NPC.cpp b/src/Actor/NPC.cpp index f7a797f..f2b2ed1 100644 --- a/src/Actor/NPC.cpp +++ b/src/Actor/NPC.cpp @@ -1,7 +1,7 @@ #include "NPC.h" NPC::NPC(void) { - _NPC->CreateAABBFromSprite("../Data/Img/Player"); + _NPC = new Sprite(); } NPC::~NPC(void) { @@ -13,5 +13,5 @@ void NPC::Update(void) { } void NPC::Render(void) { - //_NPC-> + _NPC->Draw(); } diff --git a/src/Actor/NPC.h b/src/Actor/NPC.h index e5064e3..f283294 100644 --- a/src/Actor/NPC.h +++ b/src/Actor/NPC.h @@ -1,5 +1,5 @@ #pragma once -#include "../Collision/AABB.h" +#include "../Sprite/Sprite.h" class NPC { public: @@ -10,5 +10,5 @@ public: void Render(void); private: - AABB* _NPC; + Sprite* _NPC; }; diff --git a/src/Actor/Player.cpp b/src/Actor/Player.cpp index 9e67ab8..be9e269 100644 --- a/src/Actor/Player.cpp +++ b/src/Actor/Player.cpp @@ -6,21 +6,9 @@ Player::Player(void) { PLAYER_SPEED = 15; _rotationAngle = 0.0f; - _allowCollision = true; - _notColliding = false; - _blueCollision = false; _player = new Sprite(); _player->LoadSprite("../Data/Img/Player.png"); - // Loading of sprites and collision details. - // This should be directed to a collision sheet. - _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().x, _collisionBound->GetMax().y); - _stepSFX[0] = sfxManager.Load("../Data/SFX/step_cloth1.wav"); _stepSFX[1] = sfxManager.Load("../Data/SFX/step_cloth2.wav"); _stepSFX[2] = sfxManager.Load("../Data/SFX/step_cloth3.wav"); @@ -30,17 +18,9 @@ Player::Player(void) { Player::~Player(void) { delete _player; - delete _collisionBound; } void Player::Update(void) { - // Position and collision bound with the player. - _collisionBound->SetPositionOffset(_player->GetX(), _player->GetY()); - _environmentCollisionBound->SetPositionOffset(_player->GetPosition().x, _player->GetPosition().y); - - // Time to process the collisions. - ProcessCollisions(); - // Process events here. ProcessEvents(); } @@ -50,32 +30,6 @@ void Player::Render(void) { _player->Draw(); } -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; - - //if(_environmentCollisionBound->InCollision()) -} - -void Player::EntityCollisionTest(void) { - -} - -void Player::ActorCollisionTest(void) { - -} - -bool Player::GetInBlueCollision(void) { - return(_blueCollision && _preventMovement != NONE); -} - void Player::ProcessEvents(void) { float oldX = x = _player->GetX(); float oldY = y = _player->GetY(); @@ -103,7 +57,7 @@ void Player::ProcessEvents(void) { } while(sfxIndex == _lastStepSFXPlayed); SoundEffect::Play(_stepSFX[sfxIndex], 1, 0); - + _lastStepSFXPlayed = sfxIndex; } } diff --git a/src/Actor/Player.h b/src/Actor/Player.h index e24088d..6b86ba0 100644 --- a/src/Actor/Player.h +++ b/src/Actor/Player.h @@ -1,6 +1,5 @@ #pragma once #include "../Sprite/Sprite.h" -#include "../Collision/AABB.h" #include "../Global/Globals.h" #include "../System/Debug.h" #include "../IO/Input.h" @@ -34,16 +33,6 @@ public: // --- 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); int GetX(void) { return x; } @@ -58,16 +47,8 @@ private: Sprite* _player; float _rotationAngle; - // --- Collisions. - bool _allowCollision; - bool _notColliding; - bool _blueCollision; - Facing _preventMovement; - AABB* _collisionBound; - AABB* _environmentCollisionBound; - SoundEffect* _stepSFX[4]; int _lastStepSFXPlayed; }; diff --git a/src/Main/Game.cpp b/src/Main/Game.cpp index b82ec4c..ac62002 100644 --- a/src/Main/Game.cpp +++ b/src/Main/Game.cpp @@ -17,7 +17,8 @@ Game::Game(void) { _player = new Player(); - _level = new Level(); + //_NPC = new NPC(); + _level = new Level(); //_rotationAngle = 0.0f; } @@ -74,11 +75,13 @@ void Game::Render(void) { // Render our shit.. _level->Draw(xOffset, yOffset); _player->Render(); + //_NPC->Render(); } void Game::Shutdown(void) { Debug::logger->message("\n ----- Cleaning Engine -----"); delete _player; + delete _NPC; delete _level; } diff --git a/src/Main/Game.h b/src/Main/Game.h index 0755563..b4445cb 100644 --- a/src/Main/Game.h +++ b/src/Main/Game.h @@ -1,5 +1,6 @@ #pragma once #include "../IO/Input.h" +#include "../Actor/NPC.h" #include "../Actor/Player.h" class Sprite; @@ -21,5 +22,6 @@ public: private: Player* _player; - Level* _level; + NPC* _NPC; + Level* _level; };