Repository navigation
A Quick Start Guide to Braising
When using the Braise Engine, all of your game logic should be in the Game.cs file (GameCode class).
The structure of the GameCode class is basically identical to a Monogame Game class, that being you have an Initialize function where you initialize any variables or objects, a LoadContent function, where you load any of your content, a Update function that gets called every frame, and a Draw function where you put your rendering code (if using Renderer components, this function can be mostly ignored).
The GameCode can access a variable currentScene, which is the scene that's currently loaded, if you wanna initialize any GameObjects into this scene, simply do:
currentScene.gameObjects.Add(your Game Object);
and to find any GameObjects in your scene, simply do either:
currentScene.FindGameObject(name);
or for multiple instances:
currentScene.FindGameObjects(name);
Each GameObject has a name, a Tag, a list of components, and a Transform.
To move a GameObject, you simply need to change its Transform.
To change the position do:
GameObject.transform.position = desired position;
to change its rotation do:
GameObject.transform.rotation = desired Z axis rotation;
and to change its scale do:
GameObject.transform.scale = a multiple of the size (for example 2 would be 2x the size of the sprite);
To add a Component to a GameObject do:
GameObject.AddComponent(component object);
and to find a Component do:
GameObject.GetComponent(component class type);
and for multiple instances of the component:
GameObject.GetComponents(component class type);
When creating an instance of a component we need to pass the component its parent GameObject, so when we're instantiating a component, we do it like this:
MyComponent component = new MyComponent(GameObject, any other arguments the component needs);
If we want the GameObject to be rendered in the scene, we need to give it a renderer, we can either give it a regular Renderer, or for simpler objects we can use BasicRenderer instead.
We can create a Renderer multiple ways.
Either by giving it a already loaded sprite:
Renderer render = new Renderer(GameObject, sprite);
Or by giving it the path to a sprite that it should load:
Renderer render = new Renderer(GameObject, sprite path);
And of course, to add the renderer to our GameObject, we simply do:
GameObject.AddComponent(render);
The Engine also has a Collision Detection system. There are currently only CircleCollider and RectangleCollider, which are a collider with the shape of a circle and rectangle respectively. To create one we do:
CircleCollider collider = new CircleCollider(GameObject, radius, offset);
or:
RectangleCollider collider = new RectangleCollider(GameObject, Rectangle);
If we want to check if a collider is colliding with any other collider, we simply call the method CheckForCollision:
bool isColliding = Collider.CheckForCollision(other collider);
All Colliders are derived from the Collider class, meaning we can pass any collider to this function.
There's also a simple CharacterController component, to create it we do:
CharacterController controller = new CharacterController(GameObject);
Unlike working with base GameObjects, a CharacterController moves the GameObject on its own, based on the Velocity variable, and stops whenever it touches another collider, thus if we wanna move the GameObject, we can simply do:
CharacterController.velocity = direction of motion