Tile engine

Describtion of how a TileEngine should work.

A object should not add another object to a field.

The main loop

The main loop consiste of the folowing three steps:

  • Objects gather information for changing the status, this information can be requested from other objectss etc. Or from the received messages. During this step nothing should change.
  • Objects update their status, chang the currect status and send messages.
  • Updating the screen, processing user input, etc

Gathering information

In this step all objects gather information from other objects, and the received messages, so that it has all information for changing the status and sending messages, because when this is started other objects might have changed. Absolutely nothing should be changed during this step.

Update status

In this step objects change their status and send messages, information for this is already gathered in the Gathering information step.

Updating the screen, processing user input, etc

In This step, Non-objects can do things, send message to the objects for use input. Update the screen, and everything else.

The good point of using such an gatherinformation-update status is that nothing changes when you're gathering information and the nothing has precedence over something else, the drawback however is that you have to store somewhere what you're gona change. Also things can happen simutaniesly.

Messages

Much of the information is send though messages.

Messages structure

Messages is a simple object, with only a new property for the type of the message. It is recommended to make descendant from TTileMessage to include more information, and always use this messages incombination with a specific message type.

Recieving messages

A object has a list with all received messages, this list is cleaned after the gathering information step.

Sending messages

Messages may only be during the Update Status step. If a messages is send is specifies the receiver(s) and the message. Messages are semi-referenced counted, and after sending you should Release the message, the receivers also Release the message when clear the messages.

Standard messages

There two standard messages:

ObjectAdded:
This is recieved when a object is added to the object.
ObjectRemoved:
This is recieved when a object is removed.

Change Log

0.0.0.1
Message are now semi-reference counted instead of lose control.
0.0.0.0:
First version.