Level - JayhawkZombie/EECS581Project GitHub Wiki
In SFEngine > Source > Headers > Level > BasicLevel.h
Derives from BaseEngineInterface
This is most basic level class that used to actually play a game level. It cannot be instantiated on its own and you must derive from it to create customized level.
Construction
Only a single constructor exists:
BasicLevel(const sf::Vector2u &LevelSize, const sf::FloatRect &DefaultView, bool showlines = false, const sf::Vector2f &GridSpacing = { 0,0 })
You must use this when instantiating it. Derived classes may have a default constructor, but then must explicitly invoke the BasicLevel constructor in their constructor's initializing list:
-
Such as in the StartupLevel example:
StartupLevel::StartupLevel() : BasicLevel(sf::Vector2u(1700, 900), sf::FloatRect(0, 0, 1700, 900)) { ... }
Methods
virtual void TickUpdate(const double &delta) override
- overridden from BaseEngineInterface
virtual void Render(std::shared_ptr<sf::RenderTarget> Target) override
- overridden from BaseEngineInterface
virtual void RenderOnTexture(std::shared_ptr<sf::RenderTexture> Texture)
- Specific to the level classes. An explicit request to render your level onto a render texture instead of a generic render target. See sf::RenderTexture for documentation on RenderTexture
virtual void OnShutDown() override
- overridden from BaseEngineInterface
virtual void SerializeOut(std::ofstream &out)
- overridden from BaseEngineInterface
virtual void SerializeIn(std::ifstream &in)- overridden from
BaseEngineInterface
virtual void HandleInputEvent(const UserEvent &evnt) override
- overridden from BaseEngineInterface
DEPRECATED virtual void HandleKeyPress(const sf::Keyboard::Key &key)
- An explicit request to handle a user's key press action
DEPRECATED virtual void HandleKeyRelease(const sf::Keyboard::Key &key)
- An explicit request to handle a user's key release action
virtual void OnBegin()
- Called when the level starts
virtual void OnEnd()
- Called when the level exits
virtual void HideUI()
- A request from the engine for the level to remove its TGUI elements from the Engine::GUI structure
virtual void ShowUI()
- A request from the engine to add its TGUI elements to the Engine::GUI structure
virtual void Reset()
- A request for the level to reset itself (think "Restart")
virtual void SpawnActor(std::shared_ptr<GenericActor> Actor, const sf::Vector2f &Position)
- Spawn an actor at the specified position
- This will:
- Change the object's internal and user-exposed IDs
virtual void SpawnObject(std::shared_ptr<LevelObject> Object, const sf::Vector2f &Position)
- Spawn an object at the specified position
- This will:
- Change the object's internal and user-exposed IDs
virtual bool SpawnAutoGeneratedObject(std::shared_ptr<LevelObject> Object, std::string IDPrePend = "")
- Spawn an auto-generated object
- Currently called by
SpawnActor
andSpawnObject
- The side-effects are identical to that of
SpawnActor
andSpawnObject
- Returns
true
is the spawn was successful and no errors occurred
virtual void LoadFromFile(const std::string &file)
- Load the level from a file (file will be Json formatted)
virtual void LoadAssets(const Json::Value &value)
- Load specified assets from a project file
virtual void LoadAudio(const Json::Value &value)
- Load audio specified in the project file
virtual void LoadTextures(const Json::Value &value)
- Load textures specified in the project file
virtual void LoadTileSheets(const Json::Value &value)
- Load and set up tile sheets specified in the project file
virtual void LoadSheet(const Json::Value &value)
- Load a specific tile sheet as specified in the project file
virtual void LoadAnimations(const Json::Value &value)
- Load animations as specified in the project file
virtual void CleanUp()
- Called to instruct the level to clean up any resources necessary
virtual void UpdateObjectPhysics()
- Update the physics for all level objects. Does all collision detection
Members
bool DoUpdatePhysics
- Whether or not to update physics. true
by default
float updateInterval
- The number of ms to wait between physics updates. 16.667
by default
sf::FloatRect CurrentView
- The current part of the level that can be seen
sf::Vector2u Size
- The size of the level (usually in pixel coordinates)
sw::TileMap TileMap
- a SelbaWard tile map provided. See Selba Ward for documentation
::vec2d *Gravity
- A pointer to a vec2d
instance, representing the force of gravity in the level. Used by the physics engine for properly applying gravity to physics
std::map<std::string, std::shared_ptr<Engine::LevelObject>> LevelObjects
- The levels collection of level objects
WeatherSystem m_WeatherSystem
- the levels WeatherSystem
std::vector<SegmentPtr> Segments
- the levels collection of segHit objects. These are just line segments that prevent other collision objects from passing through them. These are in a separate container because the physics engine requires the mvHit
and segHit
objects be differentiated to properly apply physics
std::map<std::string, std::shared_ptr<sf::Texture>> Textures
- The levels collection of textures loaded. All the textures specified in the project file will be loaded into this structure. Upon LevelObject creation, you can assume every texture in the project file will be loaded and you can safely reference this structure