Rune Engine  Version 0.2.7-alpha
Documentation for how to make games using the Rune Engine.
Physics

Adding physical interactions is an important and fun part of making your game! In Rune, adding physics is as simple as attaching a physics::RigidBody component to your rune::GameObject.

In your GameObject constructor, you will be required to initialize the RigidBody in one of two ways. One way is by doing nothing, this will create a RigidBody component with infinite mass that isn't allowed to move, but other RigidBodies will collide with happily.

If you would like to have your object move, you will need to specify the mass of the RigidBody. You can do this like so:

Adding a static (non-moving) RigidBody to your GameObject.

#include <RuneEngine.h>
class Player : public rune::GameObject
{
public:
Player();
};

Giving your RigidBody movement.

After you have initialized a RigidBody in your GameObject header file, go ahead and apply it to the GameObject. Remember that both of the arguments in the RigidBody constructor are optional, and can be left out completely. Refer to the physics::RigidBody page for more information about these parameters.

#include "player.h"
Player::Player()
: myBody(10,rune::Vec2(0,-10))
{
addComponent(myBody);
}

Now your object will be subjected to gravity and collisions!

physics::RigidBody
Game object component that allows a game object to have collisions with other objects.
Definition: rigidBody.h:95
rune
The main namespace to be used for interfacing with the engine.
Definition: animator.h:21
rune::GameObject
Entity control system main object used for all objects in the scene.
Definition: gameObject.h:23