Ameen AltajerAI & Search Engineering

Precious Engine/08 of 9

Using Precious Engine

Why there is no level editor, and how to organize a scene so Android can reclaim it.

I know that a lot of people are comfortable with game engines that contain a world editor, allowing you to shape your game without touching the engine's code. I'm still thinking about building a world editor for Precious Engine. However, I really encourage you to think about making sample games, or even demos, by programming the whole thing without using a level editor.

It's hard, yes I know. But this will give you a very good understanding of what really goes under the hood.

You'll notice, looking at the example I attached, that keeping a separate class for each of these to a single scene is a pretty neat organization:

  • Scene Resources
  • Scene World
  • The Actual Scene

This organization is good practice due to the nature of Android. You will be able to separate the resources of each scene from the actual scene. Android may kill the process of the game if it needs to, and with this organization you can load the resources again in case they have been deallocated. The same concept goes to the Scene World, where you will keep all objects.

You will notice that there are render functions in various areas, and for the time being the rendering happens on the CPU using the Canvas class provided by Android, and the GPU is left untouched. This is not efficient, but it keeps everything simple and allows newcomers to understand the engine a bit faster.

You'll also see that most update functions have the same parameters:

  • Elapsed Time. The time taken for the previous frame, so you can use it for various behaviors like object movement, rotation or anything relevant.
  • Event Packet. The packet which comes from the events queue, so you can handle the event.
  • World. The world which all of the other objects are located in, allowing you to access any object of the world to interact with it.