Primitives & Building Blocks
Indigo is made of several projects, but two of particular note are Indigo itself, and "Indigo Extras".
Although it's called the "Extras" project, and is completely optional, it nonetheless contains some useful types and constructs to help you build your games, such as Buttons and some pre-made SubSystems like an FPS counter, automata, and an asset loader.
The important thing about the extras project is that everything in it is derived from the building blocks provided by indigo itself. You could rebuild all of it yourself without having to modify the core in anyway, and indigo doesn't depend on anything in the extras project.
What are the building blocks in use?
Scene graph nodes
When you put together a scene to be rendered, you are building a graph, known as a "Scene Graph" - it's really just a tree of things to draw, and Indigo's notion of a scene graph is fairly simplistic and gloriously anemic.
Each element of the graph is called a node, and there are different types of node.
Non-Renderable Node Types
Non-renderable nodes are nodes that are meaningless except in the context of other nodes.
Group
A group is an element that is removed at render time - but it is used to help organise elements together. Putting several graph nodes into a group allows you to transform them as one unit, any elements that have their own properties set under the group, do so relative to the groups properties. You can also nest groups under groups.
Renderable Node Types
All renderable nodes come with the same set of basic transforms that you see on a clone:
- Depth (see below)
- Position
- Rotation
- Scale
- Alpha
- Flip horizontal
- Flip vertical
They are then specialised to do certain jobs.
BlankEntity
Represents nothing more than a space on the screen that you can manipulate and paint into, by providing a ShaderData
instance.
Useful when you want total rendering control with none of the built in frills and opinions of the other primative types.
Text[M <: Material]
Provides basic support for rendering text onto the screen, including things like alignment.
Requires you to have registered a FontInfo
instance that you can link to using a FontKey
.
TextBox
Provides a quick way to put font based rendering text onto the screen. Unlike Text
, requires no special set up unless you want to use custom fonts. However, where Text
is pixel perfect, TextBox
is limited to what the browser can render and text will look fuzzy at high magnifications.
Graphic[M <: Material]
The simplest type of drawn element, simply renders a bitmap (which may be cropped) onto the screen.
Sprite[M <: Material]
Essentially an animated graphic. You need to provide an AnimationKey
to link back to your registered Animation
information, and then you can instruct the sprite to change animation cycles, and play or stop.
Clip[M <: Material]
An even simpler animation primitive than Sprite
, Clip
is a super lightweight way to get simple animations into your game that requires little setup.
The Event Loop
The glue that binds the whole thing together is the event system. Events allow you to communicate through time and space from one component to another. Indigo's event life cycle is very strict. Events triggered in this frame will only be apparent in the next frame, available to all, and then expire (unless propagated again).