Create level and initiate it with a rigidbody etc
This commit is contained in:
parent
df7801336a
commit
d08e999f07
|
@ -55,7 +55,7 @@ struct Game::PrivateData
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicArray<PlayerData*> players;
|
DynamicArray<PlayerData*> players;
|
||||||
SmartPointer<Level> level;
|
SmartPointer<LevelData> level;
|
||||||
Utility::WinTimer timer;
|
Utility::WinTimer timer;
|
||||||
|
|
||||||
}myData;
|
}myData;
|
||||||
|
@ -88,6 +88,16 @@ Game::PlayerData* Game::CreatePlayer()
|
||||||
return this->myData->players[id];
|
return this->myData->players[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Game::LevelData* Game::CreateLevel()
|
||||||
|
{
|
||||||
|
Level *newLevel = new Level();
|
||||||
|
newLevel->InitiateLevel(1000);
|
||||||
|
LevelData *newLdata = new LevelData();
|
||||||
|
newLdata->level = newLevel;
|
||||||
|
myData->level = newLdata;
|
||||||
|
return myData->level;
|
||||||
|
}
|
||||||
|
|
||||||
void Game::CreateTeam()
|
void Game::CreateTeam()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,19 @@ namespace GameLogic
|
||||||
int GetTeamID() const;
|
int GetTeamID() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DANBIAS_GAMELOGIC_DLL LevelData
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
friend class Game;
|
||||||
|
Level *level;
|
||||||
|
LevelData();
|
||||||
|
~LevelData();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game(void);
|
Game(void);
|
||||||
~Game(void);
|
~Game(void);
|
||||||
|
@ -75,10 +88,15 @@ namespace GameLogic
|
||||||
void GetAllPlayerPositions() const;
|
void GetAllPlayerPositions() const;
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Creates a player and returns PlayerData containing ID of the player
|
* Creates a player and returns PlayerData
|
||||||
********************************************************/
|
********************************************************/
|
||||||
PlayerData* CreatePlayer();
|
PlayerData* CreatePlayer();
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Creates a level and returns LevelData
|
||||||
|
********************************************************/
|
||||||
|
LevelData* CreateLevel();
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Creates a team
|
* Creates a team
|
||||||
********************************************************/
|
********************************************************/
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include "Game.h"
|
||||||
|
#include "Level.h"
|
||||||
|
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
Game::LevelData::LevelData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Game::LevelData::~LevelData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -51,14 +51,22 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
void Level::InitiateLevel(float radius)
|
void Level::InitiateLevel(float radius)
|
||||||
{
|
{
|
||||||
API::SphericalBodyDescription sbDesc;
|
API::SphericalBodyDescription sbDesc;
|
||||||
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,0);
|
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
|
||||||
sbDesc.ignoreGravity = true;
|
sbDesc.ignoreGravity = true;
|
||||||
sbDesc.radius = radius;
|
sbDesc.radius = radius;
|
||||||
sbDesc.mass = 1e16; //10^20
|
sbDesc.mass = 1e16; //10^16
|
||||||
sbDesc.subscription = CollisionManager::LevelCollision;
|
sbDesc.subscription = CollisionManager::LevelCollision;
|
||||||
|
|
||||||
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||||
|
API::Instance().AddObject(rigidBody);
|
||||||
|
|
||||||
|
API::Gravity gravityWell;
|
||||||
|
|
||||||
|
gravityWell.gravityType = API::Gravity::GravityType_Well;
|
||||||
|
gravityWell.well.mass = (float)1e16;
|
||||||
|
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
|
||||||
|
|
||||||
|
API::Instance().AddGravity(gravityWell);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue