Question about Manual render tilemap

Hi everyone and Defold team.

I want to make a top down game, it’s a maze like Pacman game that player will moving in some paths surround by walls. Please help me.

So I drew a maze with tilemap, and also wrote a 2 dimension table in code, to know which block is the wall (value:1) and which block is the movable path (value:0).
I don’t use physics collision because it’s too unreliable especially the friction will slow down the movement. And I used that table to calculate A* path, unmovable path and other stuff.

But now I want to simplify my work:

  1. Just manual render the tilemap from my table (value 1 is wall, value 0 is movable path). But it’s hard to imagine the playground.

  2. Or somehow scan the tilemap file that I drew to detect which block is painted (wall) and which block is not (movable path).

And all block have exact size (a square with 16x16 pixels)

Hope everyone understand what I am saying and give me an advice what and how to do.
Thank so much.

IMO, use Tiled to draw your level layouts, and use its exported .lua files to set your tilemap and game data. You’ll loop through the .lua file and set each tile with tilemap.set_tile() based on the data in the .lua. Get a copy of Tiled, and see how the Lua file it generates looks like.

You can use tilemap.get_bounds() along with tilemap.get_tile() too to get information about each cell in your tilemap to setup your array.

Did I misunderstand your question?

2 Likes

Thank you for your help so much, I will give it a try after my lunch time.
Thank you again Pkeod.

1 Like