Arctic Edge devlog #2: entity

Published 1 Comment on Arctic Edge devlog #2: entity

This is the second post on a series about the development of Arctic Edge, a stealth-action game I’m working on. If you missed the previous post click here or here for the whole series.

The entity or parent entity is the base I’m using for each of the game actors like the player, enemies or bullets. It has a series of properties and mechanisms that are common to all of this actors. For example all entities have a speed in the X axis and one in the Y axis. All entities also have a max speed and an acceleration.

Besides common variables I also have common behaviour that is shared between entities. I’m placing this common behaviour in the step event of the parent entity and I leave the begin step and end step events empty to be used on the child entities. The way it works is as it follows:

  • Begin step event: in each of the child entities it is used to define input. That means that in the player entity I take care of user input while in the enemies a estate machine define which action will be performed on that frame.
  • Step event: All entities have a speed, direction, etc. and this event makes use of them to move the entity around, detect collisions, etc. This event is defined in the parent entity object.
  • End step event: As of now this event is also used exclusively on the child entities. It’s reserved mainly for managing animation and sfx but it can be also used for other tasks.

The step event is equally divided into three sections or blocks of code that are executed in the following order:

  • Pre-movement: uses the forces defined in the begin step event to determine the speed of the object in both axis.
  • Move Y: Moves and handles collisions in the Y axis
  • Move X: Moves and handles collisions in the X axis

This is how it works as of now. Maybe I will have to add some more stuff in the future but right now I’m keeping it as simple as I can.

As you see it’s a pretty simple system but it allows me to have my code organized easily and delegate common actions into a parent entity. Is this the best approach? I honestly don’t know but so far seems to be doing what I need. In the next post I will dive deep into the enemy estate machine and how I’m implementing its behaviour.

1 comment

Leave a comment

Your email address will not be published.