You can build the STE example with:
> ./makedata.sh > make clean; make
This will build 7 programs (tutor4a-tutor4g.prg) which should execute consecutively from the auto folder.
You can build the STF version of tutor4g with:
> ./makedata-stf.sh > make clean; make stf
This will build 1 program (stf.prg) which should execute from the auto folder.
This tutorial will introduce Entities and demonstrate how much can be done using them with very little code.
The Entity system is the most important and useful part of AGT, because it provides a way to populate the game world with objects which have a life of their own, and which can interact with and respond to other objects.
Our Entity tutorial continues here:
Tutorial 4a: From Sprites to Entities
Tutorial 4b: The Thinking Entity
Tutorial 4c: Independent Entities
Tutorial 4d: Entities in Local Coordinates #1
Tutorial 4e: Entities in Local Coordinates #2
Tutorial 4f: Smarter Entities
Tutorial 4g: Finishing Touches
Entities can be summarised as follows:
entity is of a specific
type. A type might represent a spaceship, a rock or a player character. The types are user-defined. There is no practical limit to the number of types which can be defined. Each project can define its own types. The types are each given a unique number.
type has default characteristics which are specified in a global
dictionary. These default characteristics are copied into every
instance spawned of that
type can be instanced multiple times in the same game world. This is called
spawning. For example you may define an entity of
type TREE and then instance 30 TREEs at various places on the game map. The default characteristics for TREE are copied into every TREE
instance has its own
state - it's own potentially unique characteristics. For example two TREEs will typically have different world coordinates. Two animated FIRE entities will likely have separate animation frames showing at any time. Two instances with complex AI behaviour will occupy different thinking states at different times.
Entities have an optional 'thinking' or
tick function. This allows each instance to reason about its own state, and to an extent, the state of significant others. A
tick function can modify nearly everything about an entity instance, including its own
Entities have an optional interaction or
collide function. This allows each instance to respond to others touching it, if they are capable of doing so. The
collide function can edit the state of the affected entity or the entity which affected it.
Last, entities have a draw method which can be one of several builtin methods, a custom method, or nothing (invisible). The draw method can be changed at any time. To accommodate drawing, an asset may be attached which provides the material to be drawn.