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 "CollisionManager.h"
using namespace GameLogic;
using namespace Oyster::Physics;
using namespace Utility::DynamicMemory;
DynamicObject::DynamicObject(std::wstring objFile)
:Object(objFile)
struct DynamicObject::PrivateData
{
rigidBody->SetSubscription(CollisionManager::BoxCollision);
PrivateData()
{
}
~PrivateData()
{
}
}myData;
DynamicObject::DynamicObject()
{
myData = new PrivateData();
}
DynamicObject::~DynamicObject(void)
{
}
void DynamicObject::Update()
{
//update object
delete myData;
}

View File

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

View File

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

View File

@ -15,7 +15,8 @@ namespace GameLogic
GameMode(void);
~GameMode(void);
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 "StaticObject.h"
#include "DynamicObject.h"
#include "GameMode.h"
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)
{
myData = new PrivateData();
}
Level::~Level(void)
{
delete myData;
}

View File

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

View File

@ -1,57 +1,48 @@
#include "Player.h"
#include "OysterMath.h"
#include "CollisionManager.h"
#include "Weapon.h"
using namespace GameLogic;
using namespace Oyster::Physics;
Player::Player(std::wstring objFile)
:Object( objFile )
struct Player::PrivateData
{
life = 100;
rigidBody->SetSubscription(CollisionManager::PlayerCollision);
PrivateData()
{
weapon = new Weapon();
}
~PrivateData()
{
if (weapon)
{
delete weapon;
}
}
int life;
Weapon *weapon;
}myData;
Player::Player()
{
myData = new PrivateData();
}
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()
{

View File

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

View File

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

View File

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

View File

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

View File

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