Platform Data Engine 0.0.1
A data-driven game engine for platformers
PlatformDataEngine::GameWorld Class Reference

Represents a game world with it's own tile map and gameObjects More...

#include <GameWorld.h>

Inheritance diagram for PlatformDataEngine::GameWorld:

Classes

struct  PlayerSpawn
 

Public Member Functions

void init (const std::string &filePath, sf::View &view, ApplicationMode appMode)
 Initializes the game world with a world.json definition file and a view as defined by the game wrapper More...
 
void initClient (const std::string &filePath, sf::View &view)
 
void initPhysics ()
 
void update (const float &dt, const float &elapsedTime)
 Update loop, calls update on the tileMap, gameObjects and the camera controller More...
 
void physicsUpdate (const float &dt, const float &elapsedTime)
 Updates the physics simulation More...
 
virtual void draw (sf::RenderTarget &target, sf::RenderStates states) const
 Draw call, never call explicitly More...
 
void registerGameObject (const std::string &name, std::shared_ptr< GameObject > gameObject)
 Registers a game object with a id (places it in the world's gameObjects map) More...
 
void registerGameObjectDefinition (const std::string &name, std::shared_ptr< GameObject > gameObjectDef)
 Registers a gameObject definition, similar to registerGameObject() but it stores an actual gameObject rather than a pointer More...
 
void loadGameObjectDefinitions ()
 
std::shared_ptr< GameObjectspawnGameObject (const std::string &type, sf::Vector2f position, std::string id="", bool noReplication=false, float rotation=0, sf::Vector2f origin={ 0.0, 0.0 }, bool alreadyReplicated=false)
 
std::map< std::string, std::shared_ptr< GameObject > > & getGameObjects ()
 
std::shared_ptr< b2World > getPhysWorld () const
 
std::shared_ptr< TileMapgetTileMap () const
 
CameraControllergetCameraController ()
 
sf::View getView () const
 
std::shared_ptr< GameObjectgetGameObject (const std::string &search)
 
GameObjectgetPlayer () const
 
GameObjectgetPlayer (std::shared_ptr< Connection > conn) const
 
std::map< std::string, std::shared_ptr< GameObject > > & getGameObjectDefs ()
 
std::string spawnPlayer (std::shared_ptr< Connection > conn)
 
void setPlayer (GameObject *player)
 
void addPlayerSpawn (PlayerSpawn &spawn)
 
void setInGame (bool inGame)
 
bool getInGame ()
 
std::map< std::shared_ptr< Connection >, GameObject * > getPlayers () const
 

Detailed Description

Represents a game world with it's own tile map and gameObjects

Member Function Documentation

◆ draw()

void GameWorld::draw ( sf::RenderTarget &  target,
sf::RenderStates  states 
) const
virtual

Draw call, never call explicitly

◆ init()

void GameWorld::init ( const std::string &  filePath,
sf::View &  view,
ApplicationMode  appMode 
)

Initializes the game world with a world.json definition file and a view as defined by the game wrapper

the path to the world definition file

a view that has been linked to a window

◆ physicsUpdate()

void GameWorld::physicsUpdate ( const float &  dt,
const float &  elapsedTime 
)

Updates the physics simulation

delta time

elapsed time (since game started)

◆ registerGameObject()

void GameWorld::registerGameObject ( const std::string &  name,
std::shared_ptr< GameObject gameObject 
)

Registers a game object with a id (places it in the world's gameObjects map)

a unique id for the gameObject

a pointer to the gameObject

◆ registerGameObjectDefinition()

void GameWorld::registerGameObjectDefinition ( const std::string &  name,
std::shared_ptr< GameObject gameObject 
)

Registers a gameObject definition, similar to registerGameObject() but it stores an actual gameObject rather than a pointer

a unique id for the gameObject definition

the gameObject "template" definition

◆ update()

void GameWorld::update ( const float &  dt,
const float &  elapsedTime 
)

Update loop, calls update on the tileMap, gameObjects and the camera controller

delta time

elapsed time (since game started)


The documentation for this class was generated from the following files: