made "interfaces" of most classes

This commit is contained in:
Erik Persson 2013-12-05 11:50:39 +01:00
parent 1cb880a66e
commit 63addde51e
12 changed files with 152 additions and 97 deletions

View File

@ -1,22 +1,29 @@
#include "DynamicObject.h" #include "DynamicObject.h"
#include "CollisionManager.h"
using namespace GameLogic; using namespace GameLogic;
using namespace Oyster::Physics;
using namespace Utility::DynamicMemory;
DynamicObject::DynamicObject(std::wstring objFile) struct DynamicObject::PrivateData
:Object(objFile)
{ {
rigidBody->SetSubscription(CollisionManager::BoxCollision); PrivateData()
{
}
~PrivateData()
{
}
}myData;
DynamicObject::DynamicObject()
{
myData = new PrivateData();
} }
DynamicObject::~DynamicObject(void) DynamicObject::~DynamicObject(void)
{ {
} delete myData;
void DynamicObject::Update()
{
//update object
} }

View File

@ -6,21 +6,22 @@
#ifndef DYNAMICOBJECT_H #ifndef DYNAMICOBJECT_H
#define DYNAMICOBJECT_H #define DYNAMICOBJECT_H
#include "Object.h"
namespace GameLogic namespace GameLogic
{ {
class DynamicObject : public Object class DynamicObject
{ {
public: public:
DynamicObject(std::wstring objFile); DynamicObject();
~DynamicObject(void); ~DynamicObject(void);
void Update(); void Update();
private:
struct PrivateData;
PrivateData *myData;
}; };
} }

View File

@ -3,13 +3,28 @@
using namespace GameLogic; using namespace GameLogic;
GameMode::GameMode(void) struct GameMode::PrivateData
{ {
PrivateData()
{
}
~PrivateData()
{
}
}myData;
GameMode::GameMode()
{
myData = new PrivateData();
} }
GameMode::~GameMode(void) GameMode::~GameMode(void)
{ {
delete myData;
} }

View File

@ -15,7 +15,8 @@ namespace GameLogic
GameMode(void); GameMode(void);
~GameMode(void); ~GameMode(void);
private: private:
//variabels that control what game rules the level runs on struct PrivateData;
PrivateData *myData;
}; };
} }

View File

@ -1,12 +1,42 @@
#include "Level.h" #include "Level.h"
#include "StaticObject.h"
#include "DynamicObject.h"
#include "GameMode.h"
using namespace GameLogic; using namespace GameLogic;
struct Level::PrivateData
{
PrivateData()
{
gameMode = new GameMode();
}
~PrivateData()
{
if (gameMode)
{
delete gameMode;
}
}
StaticObject** staticObjects;
int nrOfStaticObjects;
DynamicObject** dynamicObjects;
int nrOfDynamicObjects;
GameMode* gameMode;
}myData;
Level::Level(void) Level::Level(void)
{ {
myData = new PrivateData();
} }
Level::~Level(void) Level::~Level(void)
{ {
delete myData;
} }

View File

@ -1,15 +1,9 @@
////////////////////////////////////////////////// //////////////////////////////////////////////////
//Created by Erik and Linda of the GameLogic team //Created by Erik and Linda of the GameLogic team
////////////////////////////////////////////////// //////////////////////////////////////////////////
#ifndef LEVEL_H #ifndef LEVEL_H
#define LEVEL_H #define LEVEL_H
#include "StaticObject.h"
#include "DynamicObject.h"
#include "GameMode.h"
namespace GameLogic namespace GameLogic
{ {
@ -21,15 +15,8 @@ namespace GameLogic
~Level(void); ~Level(void);
private: private:
StaticObject** staticObjects; struct PrivateData;
int nrOfStaticObjects; PrivateData *myData;
DynamicObject** dynamicObjects;
int nrOfDynamicObjects;
GameMode* gameMode;
}; };

View File

@ -1,57 +1,48 @@
#include "Player.h" #include "Player.h"
#include "OysterMath.h" #include "OysterMath.h"
#include "CollisionManager.h" #include "CollisionManager.h"
#include "Weapon.h"
using namespace GameLogic; using namespace GameLogic;
using namespace Oyster::Physics; using namespace Oyster::Physics;
Player::Player(std::wstring objFile) struct Player::PrivateData
:Object( objFile )
{ {
life = 100; PrivateData()
rigidBody->SetSubscription(CollisionManager::PlayerCollision); {
weapon = new Weapon();
}
~PrivateData()
{
if (weapon)
{
delete weapon;
}
}
int life;
Weapon *weapon;
}myData;
Player::Player()
{
myData = new PrivateData();
} }
Player::~Player(void) Player::~Player(void)
{ {
delete this->rigidBody; delete myData;
} }
void Player::Update(keyInput keyPressed) void Player::Update()
{ {
if(keyPressed != keyInput_none)
{
Move(keyPressed);
}
} }
void Player::Move(keyInput keyPressed) void Player::Move()
{ {
if(keyPressed == keyInput_A)
{
Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
pos.x -= 0.1;
rigidBody->SetCenter(pos);
}
if(keyPressed == keyInput_D)
{
Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
pos.x += 0.1;
rigidBody->SetCenter(pos);
}
if(keyPressed == keyInput_S)
{
Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
pos.y -= 0.1;
rigidBody->SetCenter(pos);
}
if(keyPressed == keyInput_W)
{
Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
pos.y += 0.1;
rigidBody->SetCenter(pos);
}
} }
void Player::Shoot() void Player::Shoot()
{ {

View File

@ -1,37 +1,29 @@
////////////////////////////////////////////////// //////////////////////////////////////////////////
//Created by Erik and Linda of the GameLogic team //Created by Erik and Linda of the GameLogic team
////////////////////////////////////////////////// //////////////////////////////////////////////////
#ifndef PLAYER_H #ifndef PLAYER_H
#define PLAYER_H #define PLAYER_H
#include "Object.h"
#include "Weapon.h"
#include "IGame.h"
namespace GameLogic namespace GameLogic
{ {
class Player : public Object class Player
{ {
public: public:
Player(std::wstring objFile); Player(void);
~Player(void); ~Player(void);
/******************************************************** /********************************************************
* Update the position of the rigid body * Update the position of the rigid body
* This will be done with physics later * This will be done with physics later
********************************************************/ ********************************************************/
void Update(keyInput keyPressed); void Update();
void Move();
void Move(keyInput keyPressed);
void Shoot(); void Shoot();
private: private:
int life; struct PrivateData;
Weapon *weapon; PrivateData *myData;
}; };
} }
#endif #endif

View File

@ -2,12 +2,28 @@
using namespace GameLogic; using namespace GameLogic;
StaticObject::StaticObject(std::wstring objFile) struct StaticObject::PrivateData
:Object(objFile)
{ {
PrivateData()
{
}
~PrivateData()
{
}
}myData;
StaticObject::StaticObject()
{
myData = new PrivateData();
} }
StaticObject::~StaticObject(void) StaticObject::~StaticObject(void)
{ {
delete myData;
} }

View File

@ -11,13 +11,16 @@
namespace GameLogic namespace GameLogic
{ {
class StaticObject : public Object class StaticObject
{ {
public: public:
StaticObject(std::wstring objFile); StaticObject();
~StaticObject(void); ~StaticObject(void);
private:
struct PrivateData;
PrivateData *myData;
}; };
} }

View File

@ -2,12 +2,27 @@
using namespace GameLogic; using namespace GameLogic;
Weapon::Weapon(std::wstring objFile) struct Weapon::PrivateData
:Object(objFile)
{ {
PrivateData()
{
}
~PrivateData()
{
}
}myData;
Weapon::Weapon()
{
myData = new PrivateData();
} }
Weapon::~Weapon(void) Weapon::~Weapon(void)
{ {
delete myData;
} }

View File

@ -1,25 +1,22 @@
////////////////////////////////////////////////// //////////////////////////////////////////////////
//Created by Erik and Linda of the GameLogic team //Created by Erik and Linda of the GameLogic team
////////////////////////////////////////////////// //////////////////////////////////////////////////
#ifndef WEAPON_H #ifndef WEAPON_H
#define WEAPON_H #define WEAPON_H
#include "Object.h"
namespace GameLogic namespace GameLogic
{ {
class Weapon : public Object class Weapon
{ {
public: public:
Weapon(std::wstring objFile); Weapon(void);
~Weapon(void); ~Weapon(void);
private: private:
struct PrivateData;
PrivateData *myData;
}; };
} }