Starting your engines


In order to start the engine, we first need to make a class that extends World (main.core.univ.world.World). We've called this one GameWorld. Then, make a class that extends Screen (main.core.vis.Screen). Ours is called GameScreen. If you'd like a reference to the camera, you can instantiate one, otherwise it can be instantiated in a later method.

The camera can be assigned a Point class as it's target position in which it'll try to focus on. In this case, we've created a Player class that extends Entity, which contains a Point as its position. We send the camera the players position by using the setTargetPos() method.

Before we can start the engine we need to call linkWorldScreenCameraSet() in GlobalVars and send over the world, screen, and camera that we instantiated earlier, or a new camera if you don't need the reference. This sets up the three objects to work together.

All we need to do now is call the worlds start() method to start ticking, and the screens start() method to start rendering. It's called by our GameWorld class upon instantiation (see second image), but in order to add Entities to our world, we call the queueEntity() method. This queues the entity to be added at the end of the next tick.

If we want to use the acting package in our game for example, we simply make the desired Entities implement Actor and call queueSystem(new ActingSystem(this)) in our world class.

Get Pixel Fist Engine

Buy Now$5.00 USD or more

Leave a comment

Log in with itch.io to leave a comment.