Gambas Tile System

From PigaLore
Jump to navigation Jump to search

The Gambas Tile System is a tiling engine being written by Piga Software for use in its later projects. It is to form the basis of revamped versions of the Gambas Platform Engine, Gambas Genie and others. It is designed to be a flexible and resource efficient renderer allowing for easy scrolling and scalability.


In the final implementation there are three graphical layers made up of three distinct objects.

  • Tiles: the lowest layer of tiles that make up the basis of the world in small grid blocks. Persistent but can be reset or hidden. E.g. grass, stone, water.
  • Attributes: larger graphics drawn atop the tile layer and usually static but still mutable. E.g. trees, decor, collectibles.
  • Agents: dynamic elements that are drawn as independent entities over the world and move or animate frequently. E.g. players, NPCs, enemies.
    • Structure: dynamic, animated, but largely stationary agents such as buildings, machinery or similar.
    • Being: used for frequently moving entities utilizing aspects of the Gambas Performance System and artificial intelligence.

A similarly named and functioning scheme is used in PS Tech, but with an added height map.

Fixed Version

Technical demo

The earliest version can be traced back to the "Smooth Movement + Diagonals" demo released on September 1, 2014, wherein tile data is stored in a two-dimensional array that is displayed within a drawing area. Dynamic elements, most notably the player character, are rendered atop this as independent picture boxes. This allows sprite animation and movement to be done without having to redraw all the background tiles. This was not previously viable until the Qt 5 and GTK 3 toolkits were adopted by Gambas providing transparency. This draft was later used as the basis for Hull Breach, created for the December 2020 LibreJam contest.

Scrolling Version

Development screenshot

Although decent for single screen games, the use of this tiling system proved cumbersome when adding scrolling. If done directly, the amount of tiles required to drawn on a larger world at once proves too demanding. With that limitation in mind, development began in 2015 towards creating a system that would select only the tiles necessary to render while storing all the rest in memory. After a major breakthrough in 2018 for the adaptive tiling interface, work began on populating tile worlds in the latter part of 2019 by coordinating the dynamic elements as well as adding in the option of background props that reside directly over the tile layer.