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

Creating an Object

Start off by declaring your header file and including your components. You'll also want to declare a constructor so that these components can be added onto the rune::GameObject.

#include <RuneEngine.h>
class Player : public rune::GameObject
{
public:
rune::Sprite sprite;
rune::AnimationController animController;
physics::Collider2D collider;
//Create a constructor for object initialization.
Player();
}

After you have created your new rune::GameObject, go ahead and create a .cpp file (or just do this all in the header file) so that we can set up all these components we've just declared. For any of the components that have constructors you want to use, go ahead and declare these in the initialization line.

#include "Player.h"
Player::Player()
: sprite("Path to your sprite")
{
//Set up a default position for this object.
//Any elements not specifically added to a rune::Vec3 will be defaulted to 0.
transform.setPosition(rune::Vec3(0,0));
//You should make sure to set the scale of your object to be what you want, otherwise it will default to a 1 pixel by 1 pixel object.
transform.setScale(rune::Vec3(16,32));
//Let's add the components we declared earlier.
addComponent(sprite);
addComponent(animController);
addComponent(body);
addComponent(collider);
//This is also where you should add animations for your object.
animController.addAnimation("idle",16,2,2,"Path to your sprite sheet");
};

And that's all you need! Go ahead and add it to your rune::GameScene and hit play!

Scripting

Starting to add new functionality to a rune::GameObject is one of the most important parts of making a game. This is accomplished in Rune through the addition of a rune::Component to your rune::GameObject. You can add a new component created by you the same as any other predefined component. This is how you would go about making your own component.

#include <RuneEngine.h>
class CharacterController : public rune::Component
{
private:
//Declare data members to be used by the component here
//Pointers to components of other GameObject's are also useful to have here.
public:
void start()
{
//Things to do when the component is first initialized.
}
void update()
{
//Things to do every frame.
}
};
physics::RigidBody
Game object component that allows a game object to have collisions with other objects.
Definition: rigidBody.h:95
rune::Component::update
virtual void update()
A function for each component that is called every frame.
Definition: component.cpp:15
rune::Component
A component of a rune::GameObject, this class is used to add functionality to a object in the game wo...
Definition: component.h:23
rune::Vec3
1 x 3 vector to be used for math.
Definition: vec3.h:22
rune::Component::start
virtual void start()
A function for each component that is called once at the beginning of the components lifetime.
Definition: component.cpp:10
rune::Sprite
A sprite that can be given a texture and animated.
Definition: sprite.h:25
rune::GameObject
Entity control system main object used for all objects in the scene.
Definition: gameObject.h:23