The Table Engine
|
Controls the movement of a projectile. More...
#include <projectile_script.h>
Public Member Functions | |
ProjectileScript (float dx, float dy) | |
Constructs a ProjectileScript with specified velocity components. More... | |
void | update () override |
Updates the position of the projectile based on its velocity. More... | |
![]() | |
Script () | |
Default constructor, initializes an empty script. More... | |
Script (std::string name) | |
Constructs a Script with a specified name. More... | |
virtual | ~Script () |
Virtual destructor to allow for cleanup in derived script classes. More... | |
std::string | getName () |
Retrieves the name of the script. More... | |
GameObject * | getOwner () |
Retrieves the owner GameObject of this script. More... | |
void | setOwner (GameObject *owner) |
Sets the owner of this script. More... | |
virtual void | input () |
Virtual method for handling input. Should be overridden by derived classes. More... | |
virtual void | render () |
Virtual method for rendering operations. Should be overridden by derived classes. More... | |
Private Attributes | |
float | m_dx |
Horizontal velocity component of the projectile. More... | |
float | m_dy |
Vertical velocity component of the projectile. More... | |
Additional Inherited Members | |
![]() | |
std::string | m_name |
Name of the script, useful for identification or debugging. More... | |
GameObject * | m_owner |
Pointer to the GameObject that owns this script. More... | |
Controls the movement of a projectile.
ProjectileScript updates the position of the projectile game object based on initial velocities provided during its creation. This class ensures that the projectile moves in a straight line with the specified velocity.
Definition at line 22 of file projectile_script.h.
ProjectileScript::ProjectileScript | ( | float | dx, |
float | dy | ||
) |
Constructs a ProjectileScript with specified velocity components.
dx | The horizontal component of the projectile's velocity. |
dy | The vertical component of the projectile's velocity. |
Definition at line 10 of file projectile_script.cpp.
|
overridevirtual |
Updates the position of the projectile based on its velocity.
This method calculates the new position of the projectile by adding the velocity components to its current position, simulating movement.
Reimplemented from Script.
Definition at line 17 of file projectile_script.cpp.
|
private |
Horizontal velocity component of the projectile.
Definition at line 24 of file projectile_script.h.
|
private |
Vertical velocity component of the projectile.
Definition at line 25 of file projectile_script.h.