Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Game::SpriteMovement Class Reference

Class for sprite movement. More...

#include <sprite_movement.h>

Inheritance diagram for Game::SpriteMovement:
Component Events::Subject Events::Observer

Public Member Functions

virtual bool onUpdate (const double delta) override
 Called every engine loop. More...
 
virtual void onStart () override
 Called when the engine starts and when a new scene is loaded. More...
 
virtual void onDestroy () override
 Called when the engine is shutting down. More...
 
virtual void handleQueuedEvent (std::shared_ptr< Events::Event > event) override
 HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received. More...
 
virtual void onNotifyNow (std::shared_ptr< Events::Event > event) override
 When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes. More...
 
virtual unsigned long long getValueForSorting () const noexceptoverride
 Gets the value for sorting. More...
 
 SpriteMovement ()
 Sprite Movement constructor. More...
 
void addCollisionData (std::shared_ptr< Physics::CollisionData > collision_data)
 Adds a collision data. More...
 
void setMovingSpeed (const float speed)
 Sets the moving speed. More...
 
void setMoveQuantization (const float number_of_tiles)
 Sets the move quantization. More...
 
virtual std::string className () const noexceptoverride
 Returns a string representing the class name. More...
 
virtual std::string to_string () const noexceptoverride
 Returns a string representation of the object. More...
 
virtual void log (el::base::type::ostream_t &os) const override
 
- Public Member Functions inherited from Component
 Component ()
 Component constructor. More...
 
void setTransform (std::shared_ptr< Transform > transform)
 Sets the transform. More...
 
std::shared_ptr< TransformgetTransform () const noexcept
 Gets the transform. More...
 
void setActive (const bool active) noexcept
 Sets the component active or inactive. More...
 
bool isActive () const noexcept
 Determines if active. More...
 
unsigned int getId () const noexcept
 Gets the identifier. More...
 
bool operator< (Component &other) noexcept
 Operator < using getValueForSorting. More...
 
virtual ~Component ()
 Destroys the object. More...
 
- Public Member Functions inherited from Events::Subject
virtual ~Subject ()=default
 
virtual void notify (std::shared_ptr< Event > event)
 notify is used to tell observers of an event. More...
 
virtual void notifyNow (std::shared_ptr< Event > event)
 notifyNow is used to tell observers of an event as an interrupt. More...
 
virtual void addObserver (std::shared_ptr< Observer > observer)
 Adds an observer. More...
 
virtual void removeObserver (std::shared_ptr< Observer > observer)
 Removes an observer. More...
 
- Public Member Functions inherited from Events::Observer
virtual ~Observer ()
 
void onNotify (std::shared_ptr< Event > event)
 When receiving an event that is non-immediate, onNotify is used. The event is added to the event queue that is processed when processEventQueue is called. More...
 
void processEventQueue ()
 This should be called once ever loop for every Observer to properly use queued events. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Events::Observer
std::shared_ptr< EventgetEvent ()
 
bool eventsWaiting () const noexcept
 
- Protected Attributes inherited from Component
std::weak_ptr< Entityentity
 
std::shared_ptr< Transformtransform
 
bool active
 
unsigned int id
 
- Static Protected Attributes inherited from Component
static unsigned int next_id = 0
 

Detailed Description

Class for sprite movement.

Constructor & Destructor Documentation

Game::SpriteMovement::SpriteMovement ( )

Sprite Movement constructor.

References Game::SpriteMovementMotor::FACE_DOWN, and Component::getTransform().

Member Function Documentation

void Game::SpriteMovement::addCollisionData ( std::shared_ptr< Physics::CollisionData collision_data)

Adds a collision data.

Parameters
[in]collision_dataThe collision data

Referenced by generated::getSpriteMovementModule().

std::string Game::SpriteMovement::className ( ) const
overridevirtualnoexcept

Returns a string representing the class name.

Returns
The class name

Reimplemented from Component.

Referenced by generated::getSpriteMovementModule().

unsigned long long Game::SpriteMovement::getValueForSorting ( ) const
overridevirtualnoexcept

Gets the value for sorting.

Returns
The value for sorting.

Implements Component.

References Component::getId().

void Game::SpriteMovement::handleQueuedEvent ( std::shared_ptr< Events::Event event)
overridevirtual

HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received.

Parameters
[in]eventThe event

Reimplemented from Component.

References Game::SpriteMovementMotor::DOWN, Component::handleQueuedEvent(), Events::KEY_DOWN, Events::KEY_REPEAT, Game::SpriteMovementMotor::LEFT, Game::SpriteMovementMotor::RIGHT, and Game::SpriteMovementMotor::UP.

Referenced by onNotifyNow(), and onUpdate().

void Game::SpriteMovement::log ( el::base::type::ostream_t &  os) const
overridevirtual

Reimplemented from Component.

References to_string().

virtual void Game::SpriteMovement::onDestroy ( )
inlineoverridevirtual

Called when the engine is shutting down.

Implements Component.

void Game::SpriteMovement::onNotifyNow ( std::shared_ptr< Events::Event event)
overridevirtual

When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes.

Parameters
[in]eventThe event

Reimplemented from Component.

References handleQueuedEvent().

void Game::SpriteMovement::onStart ( )
overridevirtual

Called when the engine starts and when a new scene is loaded.

Implements Component.

References Component::getTransform().

bool Game::SpriteMovement::onUpdate ( const double  delta)
overridevirtual

Called every engine loop.

Parameters
[in]deltaThe delta
Returns
true if active

Implements Component.

References Component::active, Events::Observer::eventsWaiting(), Events::Observer::getEvent(), and handleQueuedEvent().

void Game::SpriteMovement::setMoveQuantization ( const float  number_of_tiles)

Sets the move quantization.

Parameters
[in]number_of_tilesThe number of tiles

Referenced by generated::getSpriteMovementModule().

void Game::SpriteMovement::setMovingSpeed ( const float  speed)

Sets the moving speed.

Parameters
[in]speedThe speed

Referenced by generated::getSpriteMovementModule().

std::string Game::SpriteMovement::to_string ( ) const
overridevirtualnoexcept

Returns a string representation of the object.

Returns
String representation of the object.

Reimplemented from Component.

References Component::to_string().

Referenced by generated::getSpriteMovementModule(), and log().


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