Hi everyone and happy new year!
Ovine Tilemap widget.zip *
* This widget is for Fusion 2.5 only, it would work on MMF2.0 but I plan to add actors and I need some features only found in Fusion.
Ovine Tilemap Widget
One thing I've always wanted to be easier in Fusion is a way to build a game in one level but have different screens or levels. Imagine an flip-screen exploration game like Dizzy, Manic Miner or Jet Set Willy. In these type of games you will have the same game logic covering many levels. In Fusion today you could build such a game easily over many frames, you can copy frames, use globals and event behaviors. Alternatively you can create your own level editor / viewer that runs in a single frame with all your game logic in one place making it easier to maintain, make changes and fix bugs. There are some extensions to help with this, but they are generally limited to specific runtimes. Maybe one day Clickteam will give us some objects to help with this kind of functionality but until then I thought I'd have a go at creating a widget to allow me to display a 'room' or level in one frame which works anywhere and this is what you will find here.
There are actually three widgets, two are for a basic level editor and a third for use in a game.
This version is fairly basic but works well on Windows and Android. Should work on iOS but not tested there yet.
How to use
The widgets have some alterable values which will be explained below. It also needs two objects
1) an Array object called TileArray - this stores the map data, ie: What tiles to display in your room. The X and Y dimensions of the array define a grid where each cell defines the tile to display. The Z dimension is to cater for additional 'rooms' or levels.
2) an Active object called Tileset - this contains tiles in the Stopped-Right animation. I use Fusion's new picture editor import feature that will import a 'sprite sheet' as 'Import as animation' from a tilesheet graphic you create. The first tile in the tilesheet is an invisible tile, it will never be displayed.
Tilemap Viewer Widget
This widget will read the data stored in the TileArray and paste as a backdrop the corresponding tiles found in the Tileset active object. It is currently set up to use three tilemap layers and you can choose to paste to different frame layers in Fusion.
* aNumTilesX = the number of tiles in the tilemap on the x axis.
* bNumTilesY = the number of tiles in the tilemap on the y axis.
* cTileImageWidth = the width in pixels of each tile.
* dTileImageHeight = the height in pixels of each tile.
* eDisplayRoom = the Room (starting at 0) to display.
* fLayer1 = the Fusion layer to paste the tilemap layer 1 to.
* gLayer2 = the Fusion layer to paste the tilemap layer 2 to.
* hLayer3 = the Fusion layer to paste the tilemap layer 3 to.
* aCommand = The widget will not do anything until you set this to "GO". Set the eDisplayRoom alterable value first, then set this string to "GO" to render that room number.
I have designed the widget to work each time you start a frame. To start, create an event to set the eDisplayRoom alterable value to the room you wish to display, then set the aCommand string to "GO". Your room will be created as background graphics. To change to another room restart the frame (or jump back to it) - I use a global value (A) to store the current room in the example.
There are two other widgets to help with building levels:
Tilemap Editor Widget - this is the editor space.
Tilemap Selector Widget - this is the object workshelf, the tiles you can pick from.
Both share a lot of alterable values in common with the viewer widget so I will not cover them again.
Quick note on how to use the editor: Select a tile from the Selector Widget by clicking on any in the grid. You will see a larger representation of the selected tile above. Now Left click in the Editor Widget area to draw with that tile. Right click in the Editor Widget area to select that tile to draw with (a short cut).
There are some additional buttons in the Widget-Editor frame that demonstrates how to control the level editor.
The widgets do provide the functionality I wanted but there are still features to add. I've tried to make them as flexible as possible and if they are useful to you please dive in and use them. If you make any interesting modifications please do share with the community.
I plan to add 'actors' to the next version of the widgets which will allow for active objects to be set up to be displayed within each room.