DEV Community

Kartik Patel
Kartik Patel

Posted on

How to use Tileset in Mini Micro?

Introduction

Hey fellas, welcome back to another blog today. I am going to tell you how you can use Tilset's in Mini Micro.

So let's dive in by first understanding what a Tileset is and then implementing one in Mini Micro.

Tileset

So, what is a tileset?

Short answer:
A tileset is a collection of small images (called tiles) that is used to build up a game level, especially in 2D games.

Why Use a Tileset?

  • Reuse: You don’t redraw the same tree 50 times.

  • Faster Performance: Game engines batch draw these.

  • Consistent Art Style: One palette, one size, clean look.

In Game Engines (like Godot, Mini Micro, etc):

  • You load a tileset image.
  • Cut it into tiles (16x16, 32x32, etc).
  • Then paint your levels using these tiles.

Tileset in Mini Micro

Now, as we know what a tileset is, let's try using one in Mini Micro.

Before we start:

  • In Mini Micro, there are 8 displays in total, each with a special task. Display(5) is used for tiles by default, although you can reorder these displays.

Image description

Steps to use the tileset.

First, we need to set up our display.
clear display(5).mode = displayMode.tile //setup display 5 as tileset mode td = display(5) //using td to reference display(5) td.clear //clears tile display 
Enter fullscreen mode Exit fullscreen mode
Setting Tileset Image and tile properties
td.tileSet = file.loadImage("/usr/Platformer/Sprite/tileset.png") //path of the tileset. td.tileSetTileSize = 64 //size of tile in tileset td.cellSize = 64 //size of tile in mini micro display td.extent = [150,10] //columns and rows on screen 
Enter fullscreen mode Exit fullscreen mode
Indexing tiles.

Let's say the tileset we made has 88 tiles(example below). By indexing these tiles starting from 0, we can get a specific tile of our choice easily.

Image description

Let's 1st tile from the tileset. So we would reference it as

tile1 = 0 
Enter fullscreen mode Exit fullscreen mode

Yes, it's that simple

Rendering Tiles.

In Mini Micro command td.setCell is used to display a tile on screen.

This command takes 3 arguments

  • x cordinates
  • y coordinates
  • tile

Let's say we want tile1 to be at 0,0:

td.setCell 0, 0, tile1

What if we want grass_middle(name of the tile) to start from 0,0 and end at 149,0? In Such cases, a for loop can be used:

for x in range(0, 149) td.setCell(x, 0, grass_middle) end for 
Enter fullscreen mode Exit fullscreen mode

And that's how we use a tileset in Mini Micro.

Outro

Recommended Blogs

Recommended Videos

Top comments (2)

Collapse
 
joestrout profile image
JoeStrout

Just to be clear: there is no TileDisplay in the default setup. You can pick any layer to make into one (though 5 is a good choice!).

Some comments may only be visible to logged-in visitors. Sign in to view all comments.