-
Notifications
You must be signed in to change notification settings - Fork 11
Basic engine usage (objects & calls)
Most of the "basic engine usage" Wiki is based on the SimpleGame code, so there will be examples referring to that code.
This page assumes that you have already read "basic engine initialization".
The main abstract GameObject is the class SGameObject. Every SGameObject can use three events:
-
game_start()it's executed before the engine start to run the GameLoop. (Executed on every SGameObject registered) -
game_update(float time)it's executed every frame, allowing to do game updates about position or everything you need. (Executed on every SGameObject registered withshould_update == true). Remember that doing heavy stuff on the update method can reduce the framerate. -
on_gui()it's used to draw gui element with imgui instructions. See SimpleGame MainMenu for examples.
But there are other events you can use as you prefer, there are:
spawn(), respawn(), die() and kill(). By default these methods do nothing, but you can decide to use them, for example: SimpleGame player class (Ball) use respawn() to respawn the player on the checkpoint if the player fell the platform.
Now that you have initialize the engine, it's time to use it.
As described in the previous article, there are few things to keep in mind, let's see a list:
-
A GameObjects doesn't execute
game_start(),game_update(...)andon_gui()if it hasn't been registered in the LogicManager. -
Every Component created from the ComponentsManager, must be deleted from him. This because it keep a lot of informations about the available components and all the connected stuff, so you can't just delete a Component. For example, if you load a mesh with
create_new_mesh_component(...)you must delete it callingdestroy_mesh_component(...). This is very important and valid for every kind of component. Deleting a component with a delete call will probably lead to errors immediately or in the future.
To know more, you can give a look at "basic components".
This documentation describe only a small part of the engine, since it's not made to be used by a large amount of people.
If you would like to know more about a part of the engine, how to do something, or if a part of the documentation is not correct/out of date, please open an issue and tell me.
Thank you for reading the ScrapEngine Wiki!
Getting started
Engine structure
Using the Engine