Polygon Dash
Loading...
Searching...
No Matches
ComponentPlayerInputJump Class Reference

Cause the player GameObject to jump on certain inputs. More...

Inheritance diagram for ComponentPlayerInputJump:
ComponentScript IComponent

Public Member Functions

 this (size_t owner, ComponentTransform transform, ComponentRender render)
 Set up the script.
 
int PreviewNextHeight ()
 Get the height that the GameObject will reach on the next frame.
 
void ResetGrounded ()
 Reset the state of the jump to not be grounded.
 
void StopJump (int landHeight)
 Stop jumping and remain grounded at a given height.
 
override void Update ()
 Move the GameObject to the next location based on the gravity motion.
 
- Public Member Functions inherited from ComponentScript
 this (size_t id)
 Store the owner id.
 
override void Render (SDL_Renderer *renderer, SDL_Rect *camera)
 Render the given script.
 
- Public Member Functions inherited from IComponent

Public Attributes

ComponentTransform mTransform
 The ComponentTransform of the linked GameObject.
 
ComponentRender mRender
 The ComponentRender of the linked GameObject.
 
float jumpVelocity = 0.0
 Initial velocity when the jump starts.
 
const float jumpStrength = -13.0
 Initial jump velocity (negative for upward motion).
 
const float maxVelocity = 10.0
 The maximum velocity reachable during a fall.
 
bool isGrounded = false
 Whether the player is on the ground.
 
const int groundLevel = 480
 The lowest possible ground level (the GameObject can never go below this).
 
const int ceilingLevel = 0
 The height possible ceiling level (the GameObject can never go above this).
 
const float rotationSpeed = 5.0f
 Degrees per frame while jumping.
 
bool isGravityFlipped = false
 Whether gravity is flipped to be the opposite direction or not.
 

Detailed Description

Cause the player GameObject to jump on certain inputs.

Constructor & Destructor Documentation

◆ this()

ComponentPlayerInputJump::this ( size_t owner,
ComponentTransform transform,
ComponentRender render )
inline

Set up the script.

Parameters
ownerthe id of the linked GameObject.
depththe speed to move the parallaxed GameObject..
transformthe ComponentTransform of the linked GameObject.

Member Function Documentation

◆ PreviewNextHeight()

int ComponentPlayerInputJump::PreviewNextHeight ( )
inline

Get the height that the GameObject will reach on the next frame.

Returns
the upcoming y coordinate.
See also
ComponentCollision::CheckForFloorCollision

◆ ResetGrounded()

void ComponentPlayerInputJump::ResetGrounded ( )
inline

Reset the state of the jump to not be grounded.

Run this to enter a free-fall state.

◆ StopJump()

void ComponentPlayerInputJump::StopJump ( int landHeight)
inline

Stop jumping and remain grounded at a given height.

The GameObject will stop at landHeight as if it has landed on an object.

Parameters
landHeightthe end height in pixels of the jump.

◆ Update()

override void ComponentPlayerInputJump::Update ( )
inlinevirtual

Move the GameObject to the next location based on the gravity motion.

See also
ComponentTransform

Implements ComponentScript.


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