Ogmo levels with -1 index


(Ricesteam) #1

Hey I’m a little confused with the rendering of Tilemaps of index -1. By default, my Ogmo level outputs -1 for empty spaces, however when I import the level to FP, the game renders an unexpected tile from the tileset. For example:

With the empty space (the -1 in the level.oel), one would expect FP to ignore rendering something for the current cell, however it is rendering unwanted tiles from the tile set.

Did I forget to configure something in my Ogmo project or set a flag in FP?

The work around is me modifying each .oel file and replace all -1 with 0 which corresponds to an empty tile in my tileset.


(Abel Toy) #2

Yeah, dunno why it does that.

You could always use the String replace method to load your levels, as a workaround until you figure it out…


(Alex Larioza) #3

Empty space has no tile, thus, -1 represents the absence of a tile. Without this behavior, you wouldn’t be able to differentiate between empty positions and positions that are meant to have the 0-index tile. It’s setup this way so you can set your own case for empty tile positions or doing what @AbelToy suggested (and what I usually do also).


(Zachary Lewis) #4

If you look at Tilemap, you’ll notice that all of the indices are of type uint.

Adobe’s Documentation says

The uint class provides methods for working with a data type representing a 32-bit unsigned integer. Because an unsigned integer can only be positive, its maximum value is twice that of the int class.

This means, if you try to typecast a negative integer to a uint, it’ll essentially wrap-around zero, giving you an extremely large number (which is then modified by FlashPunk to hopefully find a tile).

When working with a Tilemap, it is important to have a valid tile declared for every single square, even if the tile is just a transparent square. My first step in Ogmo is to flood-fill the entire map with either floor or wall tiles, then either carve out or block in an area for the player.


(NoelFB) #5

Your best solution to actually work around the problem is to only place a tile in the tilemap if the index >=0, and ignore it otherwise.