The Table Engine
ProjectileScript Class Reference

Controls the movement of a projectile. More...

#include <projectile_script.h>

+ Inheritance diagram for ProjectileScript:
+ Collaboration diagram for ProjectileScript:

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...
 
- Public Member Functions inherited from Script
 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...
 
GameObjectgetOwner ()
 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

- Public Attributes inherited from Script
std::string m_name
 Name of the script, useful for identification or debugging. More...
 
GameObjectm_owner
 Pointer to the GameObject that owns this script. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ProjectileScript()

ProjectileScript::ProjectileScript ( float  dx,
float  dy 
)

Constructs a ProjectileScript with specified velocity components.

Parameters
dxThe horizontal component of the projectile's velocity.
dyThe vertical component of the projectile's velocity.

Definition at line 10 of file projectile_script.cpp.

Member Function Documentation

◆ update()

void ProjectileScript::update ( )
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.

Member Data Documentation

◆ m_dx

float ProjectileScript::m_dx
private

Horizontal velocity component of the projectile.

Definition at line 24 of file projectile_script.h.

◆ m_dy

float ProjectileScript::m_dy
private

Vertical velocity component of the projectile.

Definition at line 25 of file projectile_script.h.


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