![]() |
Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
|
#include <physics.hpp>
Public Member Functions | |
| KinematicBody () | |
| KinematicBody (const std::shared_ptr< Shape > &shape) | |
| void | physicsUpdate () override |
| void | initCompute () override |
| void | setLinearVelocity (Vector2 vel) const |
| void | applyForce (Vector2 force) const |
| void | applyImpulse (Vector2 impulse) const |
| Vector2 | getLinearVelocity () const |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Public Member Functions inherited from PhysicsBody | |
| void | exit () override |
| void | initialize () override |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
| b2BodyId | getBodyId () |
| b2ShapeId | getShapeId () |
Public Member Functions inherited from Component | |
| virtual | ~Component ()=default |
| virtual void | update (float deltaTime) |
| virtual void | render (std::shared_ptr< Window > window) |
| virtual void | input (InputEvent &event) |
| virtual void | postLoad () |
| Node * | getNode () const |
| void | setNode (Node *n) |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Additional Inherited Members | |
Public Attributes inherited from PhysicsBody | |
| Signal< PhysicsBody * > | collisionEnter |
| Signal< PhysicsBody * > | collisionExit |
| Signal< PhysicsBody * > | collisionHit |
| Signal | mouseEntered |
| Signal | mouseExited |
| std::shared_ptr< Shape > | shape |
Protected Attributes inherited from PhysicsBody | |
| bool | sensor |
| b2BodyDef | bodyDef |
| b2BodyId | bodyId |
| b2ShapeId | shapeId |
| Transform | storedTransform |
The KinematicBody component is a type of PhysicsBody. The main difference between KinematicBody and any other physics body is that it does not move, at all, unless it is moved by a force or impulse or its linear velocity.
Like any other physics body, once it is attached to a node, you must not move the node through its transform property.
Example usage:
For more insight regarding anything physics related, the physics example and node tree example also utilize staticbodies!
| KinematicBody::KinematicBody | ( | ) |
|
explicit |
| void KinematicBody::applyForce | ( | Vector2 | force | ) | const |
| void KinematicBody::applyImpulse | ( | Vector2 | impulse | ) | const |
| Vector2 KinematicBody::getLinearVelocity | ( | ) | const |
|
overridevirtual |
Reimplemented from PhysicsBody.
|
inline |
|
overridevirtual |
Implements PhysicsBody.
|
inline |
| void KinematicBody::setLinearVelocity | ( | Vector2 | vel | ) | const |