[Remove] Removed AABB's for now.

[Add] Adding some NPC class stuff. Going to work on Actors now.
This commit is contained in:
Rtch90 2012-04-12 18:32:45 +01:00
parent d5ed83dce7
commit 84bfde227a
6 changed files with 12 additions and 72 deletions

View File

@ -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();
}

View File

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

View File

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

View File

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

View File

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

View File

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