Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
main.cpp File Reference
#include "Engine.hpp"
#include "Event.hpp"
#include "Object.hpp"
#include "Physics.hpp"
#include "event/CollisionEvent.hpp"
#include "resource/Time.hpp"
#include <iostream>

Classes

struct  CounterComponent

Functions

void CreateFloor (Engine::Core &core)
 Create a static floor plane using Object::CreatePlane helper.
void CreateFallingCube (Engine::Core &core, float x, float y, float z, float mass)
 Create a dynamic cube that will fall using Object::CreateCube helper.
void CreateBouncyBall (Engine::Core &core, float x, float y, float z)
 Create a bouncy ball with high restitution using Object::CreateSphere helper.
void CreateMovingPlatform (Engine::Core &core)
 Create a kinematic platform that can be moved programmatically.
void OnCollisionAdded (const Physics::Event::CollisionAddedEvent &event)
void RegisterCollisionLoggerSystem (Engine::Core &core)
void PrintSimulationStep (uint32_t step, Engine::Core &core)
 Display simulation statistics.
void RunningPhysicsSimulationSystem (Engine::Core &core)
 Runs the physics simulation system and prints info every 10 steps.
void CreatePhysicsWorldSystem (Engine::Core &core)
 Create the physics world with several entities.
void CleanupDemonstrationSystem (Engine::Core &core)
 Cleanup all created entities in the physics demonstration.
int main (void)

Function Documentation

◆ CleanupDemonstrationSystem()

void CleanupDemonstrationSystem ( Engine::Core & core)

Cleanup all created entities in the physics demonstration.

◆ CreateBouncyBall()

void CreateBouncyBall ( Engine::Core & core,
float x,
float y,
float z )

Create a bouncy ball with high restitution using Object::CreateSphere helper.

Use the helper function to create a sphere entity with mesh and transform. Add Sphere-like collider (using small cube for now as approximation), then Very bouncy properties

◆ CreateFallingCube()

void CreateFallingCube ( Engine::Core & core,
float x,
float y,
float z,
float mass )

Create a dynamic cube that will fall using Object::CreateCube helper.

Use the helper function to create a cube entity with mesh and transform. Add RigidBody component with dynamic motion type and specified mass. A ConvexHullShape is created automatically from the mesh vertices!

◆ CreateFloor()

void CreateFloor ( Engine::Core & core)

Create a static floor plane using Object::CreatePlane helper.

Use the helper function to create a plane entity with mesh and transform. Add Large flat box collider (20x1x20 meters) component for collision and Static rigid body (immovable) component.

◆ CreateMovingPlatform()

void CreateMovingPlatform ( Engine::Core & core)

Create a kinematic platform that can be moved programmatically.

Use the helper function to create a cube entity (flattened for platform shape)

◆ CreatePhysicsWorldSystem()

void CreatePhysicsWorldSystem ( Engine::Core & core)

Create the physics world with several entities.

  1. Static floor
  2. Several falling cubes with different properties
  3. Bouncy ball
  4. Kinematic platform

◆ main()

int main ( void )

◆ OnCollisionAdded()

void OnCollisionAdded ( const Physics::Event::CollisionAddedEvent & event)

◆ PrintSimulationStep()

void PrintSimulationStep ( uint32_t step,
Engine::Core & core )

Display simulation statistics.

◆ RegisterCollisionLoggerSystem()

void RegisterCollisionLoggerSystem ( Engine::Core & core)

◆ RunningPhysicsSimulationSystem()

void RunningPhysicsSimulationSystem ( Engine::Core & core)

Runs the physics simulation system and prints info every 10 steps.