28 #ifndef QPLATFORMERBODY
29 #define QPLATFORMERBODY
31 #include "../qrigidbody.h"
32 #include "../qcollision.h"
50 int platformLayersBit=0;
53 float maxFloorAngle=M_PI*0.25;
56 float movingFloorSnapOffset=10.0f;
66 float gravityMultiplier=1.0f;
68 QVector velocity=QVector::Zero();
71 QVector upDirection=QVector::Up();
72 QVector rightDirection=QVector::Right();
78 QVector horizontalVelocity=QVector::Zero();
79 QVector verticalVelocity=QVector::Zero();
85 float walkAccelerationRate=0.1f;
86 float walkDecelerationRate=0.1f;
89 bool prevJumpMode=
false;
93 int currentJumpCount=0;
94 int jumpDurationFrameCount=30;
95 int jumpFrameCountDown=0;
96 float jumpGravityMultiplier=0.4f;
97 float jumpFallGravityMultiplier=1.0f;
98 bool jumpReleased=
true;
112 CollisionTestInfo(
QBody *body=
nullptr,
QVector position=QVector::Zero(),
float penetration=0.0f,
QVector normal=QVector::Zero() ): body(body), position(position),penetration(penetration),normal(normal) {}
QBody objects are the base class for all types of bodies. Any class derived from QBody shares these m...
Definition: qbody.h:43
QPlatformerBody provides a ready-to-use foundation for character physics in platformer games....
Definition: qplatformerbody.h:40
QVector GetControllerHorizontalVelocity()
Gets the horizontal velocity controlled by the character physics.
Definition: qplatformerbody.cpp:308
QPlatformerBody * SetMaxJumpCount(int value)
Sets the maximum number of jumps allowed.
Definition: qplatformerbody.cpp:147
float GetFloorMaxAngleDegree()
Gets the maximum angle for the floor in degrees.
Definition: qplatformerbody.cpp:186
float GetJumpGravityMultiplier()
Gets the gravity multiplier during a jump.
Definition: qplatformerbody.cpp:131
bool GetIsOnFloor()
Checks if the body is currently on the floor.
Definition: qplatformerbody.cpp:621
int GetSpecificPlatformLayers()
Gets specific platform layers bit. This determines which platform layers the platformer physics will ...
Definition: qplatformerbody.cpp:164
bool GetIsRising()
Checks if the body is rising.
Definition: qplatformerbody.cpp:375
float GetMovingFloorSnapOffset()
Gets the snap offset for moving floors.
Definition: qplatformerbody.cpp:56
float GetWalkAcelerationRate()
Gets the walking acceleration rate.
Definition: qplatformerbody.cpp:102
QPlatformerBody * SetWalkAcelerationRate(float value)
Sets the walking acceleration rate.
Definition: qplatformerbody.cpp:96
QPlatformerBody * SetJumpGravityMultiplier(float value)
Sets the gravity multiplier during a jump.
Definition: qplatformerbody.cpp:125
QVector GetControllerVerticalVelocity()
Gets the vertical velocity controlled by the character physics.
Definition: qplatformerbody.cpp:319
int GetJumpDurationFrameCount()
Gets the duration for a jump in frames.
Definition: qplatformerbody.cpp:120
QPlatformerBody::CollisionTestInfo GetLeftWall(float offset)
Checks for a collision with a wall on the left.
Definition: qplatformerbody.cpp:254
float GetWalkDecelerationRate()
Gets the walking deceleration rate.
Definition: qplatformerbody.cpp:290
QPlatformerBody * SetSpecificPlatformLayers(int layersBit)
Sets specific platform layers bit. This determines which platform layers the platformer physics will ...
Definition: qplatformerbody.cpp:158
virtual void PostUpdate()
Definition: qplatformerbody.cpp:390
QPlatformerBody::CollisionTestInfo GetFloor(float offset)
Checks for a collision with the floor.
Definition: qplatformerbody.cpp:259
QPlatformerBody * SetControllerHorizontalVelocity(QVector value)
Sets the horizontal velocity controlled by the character physics.
Definition: qplatformerbody.cpp:302
QPlatformerBody * Jump(float force, bool unconditional=false)
Initiates a jump with the specified force.
Definition: qplatformerbody.cpp:324
float GetJumpFallGravityMultiplier()
Gets the gravity multiplier for the falling phase of a jump.
Definition: qplatformerbody.cpp:142
QPlatformerBody * SetControllerVerticalVelocity(QVector value)
Sets the vertical velocity controlled by the character physics.
Definition: qplatformerbody.cpp:313
float GetGravityMultiplier()
Gets the gravity multiplier.
Definition: qplatformerbody.cpp:80
QPlatformerBody * SetGravityMultiplier(float value)
Sets the gravity multiplier.
Definition: qplatformerbody.cpp:74
QPlatformerBody::CollisionTestInfo GetCeiling(float offset)
Checks for a collision with the ceiling.
Definition: qplatformerbody.cpp:275
QPlatformerBody * SetJumpDurationFrameCount(int value)
Sets the duration for a jump in frames.
Definition: qplatformerbody.cpp:114
QPlatformerBody * SetFloorMaxAngle(float value)
Sets the maximum angle for the floor.
Definition: qplatformerbody.cpp:169
QPlatformerBody * SetWalkDecelerationRate(float value)
Sets the walking deceleration rate.
Definition: qplatformerbody.cpp:107
float GetWalkSpeed()
Gets the walking speed of the body.
Definition: qplatformerbody.cpp:91
QPlatformerBody * SetWalkSpeed(float value)
Sets the walking speed of the body.
Definition: qplatformerbody.cpp:85
QPlatformerBody * SetMovingFloorSnapOffset(float value)
Sets the snap offset for moving floors.
Definition: qplatformerbody.cpp:50
QPlatformerBody * ReleaseJump()
Releases the jump phase.
Definition: qplatformerbody.cpp:361
bool GetIsJumpReleased()
Checks if the jump phase has been released.
Definition: qplatformerbody.cpp:385
QPlatformerBody * SetJumpFallGravityMultiplier(float value)
Sets the gravity multiplier for the falling phase of a jump.
Definition: qplatformerbody.cpp:136
QVector GetGravity()
Gets the gravity vector.
Definition: qplatformerbody.cpp:69
QPlatformerBody * SetGravity(QVector value)
Sets the gravity vector.
Definition: qplatformerbody.cpp:61
QPlatformerBody * Walk(int side)
Moves the body in a specified horizontal direction.
Definition: qplatformerbody.cpp:295
bool GetIsJumping()
Checks if the body is currently jumping.
Definition: qplatformerbody.cpp:380
QPlatformerBody * SetFloorMaxAngleDegree(float value)
Sets the maximum angle for the floor in degrees.
Definition: qplatformerbody.cpp:180
int GetMaxJumpCount()
Gets the maximum number of jumps allowed.
Definition: qplatformerbody.cpp:153
bool GetIsFalling()
Checks if the body is falling.
Definition: qplatformerbody.cpp:370
bool GetIsOnCeiling()
Checks if the body is currently touching the ceiling.
Definition: qplatformerbody.cpp:626
float GetFloorMaxAngle()
Gets the maximum angle for the floor.
Definition: qplatformerbody.cpp:175
QPlatformerBody::CollisionTestInfo GetPlatformCollisions(QVector testPosition, QVector nearestOnAxis=QVector::Zero())
Performs a platform collision test.
Definition: qplatformerbody.cpp:191
QPlatformerBody::CollisionTestInfo GetRightWall(float offset)
Checks for a collision with a wall on the right.
Definition: qplatformerbody.cpp:238
QRigidBody is a type of body that is simulated with the dynamics of Rigid body. A rigid body is a typ...
Definition: qrigidbody.h:40
Definition: qplatformerbody.h:107