Platform Data Engine 0.0.1
A data-driven game engine for platformers
|
Represents a game world with it's own tile map and gameObjects More...
#include <GameWorld.h>
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< GameObject > | spawnGameObject (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< TileMap > | getTileMap () const |
CameraController & | getCameraController () |
sf::View | getView () const |
std::shared_ptr< GameObject > | getGameObject (const std::string &search) |
GameObject * | getPlayer () const |
GameObject * | getPlayer (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 |
Represents a game world with it's own tile map and gameObjects
|
virtual |
Draw call, never call explicitly
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
void GameWorld::physicsUpdate | ( | const float & | dt, |
const float & | elapsedTime | ||
) |
Updates the physics simulation
delta time
elapsed time (since game started)
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
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
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)