Need a tile map tutorial!

I want to make a “pokemon like” 2d game so I needed a map where to work on. I downloaded Tiled to do so, but I wanted to learn more about tile maps first. Do you know a good tutorial where it explains how it works and how I can make one by myself? (Yes, I did google it, but none of the tutorials covered simple tile maps).

What I’m trying to understand is how to make a simple 8x8 grid of blocks without the use of an external software (just code). How feasible would that be?

One thing that you could do would be to make a level editor in Corona. This would probably be the easiest because you’re probably pretty familiar with it’s environment. I think you should make your own anyways because you’re going to need to store info like conversations and story locations in characters (in the game objects). This level editor could then export the level data to a .text file which you could just copy out of the app on your computer into another game If you find a level editor that lets you do all that then that’s probably the best tool. If you are interested in creating a level editor in Corona SDK I would be more than happy to help! I have been wanting to do this for a while :slight_smile:

As for just creating an 8x8 tiled map you could place each image manually or create a “for loop” that will place these in a grid (only useful if they’re the same image).

Tell me if you want me to go into more depth with either of these  :smiley:

Tell me if you want me to go into more depth with either of these  :smiley:

I would, in fact, really appreciate some help! I started this project just to see how I could make such a game, but now I’m much more interested in it.

I’m not sure how to make a level editor in Corona, I suppose it’s a script that places one block after the other to make a map, but I don’t know how to “export the level data”. 

Also, should I setup a repository (GitHub or so) so that we can share the code?

There’s actually an OSS tile map loader being built at the moment - http://forums.coronalabs.com/topic/29681-tiled-map-engine/

C

Yea a github repository would help, but as Caleb said, there is a tiled loader being made. Do you still want  to make your own? 

Btw what do you mean by a “script that places one block after the other”? Wouldn’t you want it so you placed the tiles yourself and then you could edit the properties of individual tiles if you wanted? 

AS, it sounds like you’re thinking of a level editor such as Gumbo, while Zoske is thinking of a level editor like Tiled. The former allows you to place images wherever you want, the latter is for making tile-based games such as the 2D Mario games (and a zillion others).

The “script that places one block after the other” is what a tiling engine does – takes a block of data such as this:

[lua]

      data = {

        39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

        39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

        39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

        39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

        39, 0, 0, 0, 0, 0, 38, 39, 39, 39, 39, 39, 39, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

        38, 0, 0, 0, 0, 0, 39, 39, 39, 39, 39, 39, 39, 39, 0, 0, 0, 0, 0, 0, 0, 38, 39, 39, 38, 0, 0, 0, 0, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 45, 39, 39, 39, 39, 39, 39, 39, 0, 0, 0, 0, 0, 0, 0, 39, 39, 39, 39, 0, 0, 0, 0, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 39, 39, 39, 39, 39, 39, 39, 39, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 38, 39, 39, 39, 39, 39, 39, 38, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0,     

      }

[/lua]

…and places the tiles in the correct spots to make this:

phasetanklvl02.png

Okay, that data was just for placement of the walls (and I chopped most of it out to save space here), there are other layers that put in floors, crates, walkways, etc. But you get the idea.

 Jay

Ooh I get it now. I thought it might be easier if it created a new table for each tile so that it would be able to store properties like conversations. Here’s what this might look like:

[lua]

level1 = {

       tile1 = {image = “image.png”, x = 100, y = 100, lines = “Hello! Welcome to narnia!”}

}

[/lua]

This would also make it easy to read the level code and edit it.

And with this it would do what you were talking about where it would run through all the tiles and place them.

Yeah, being able to attach things like conversations to a tile would be nice. With Tiled you can specify properties per tile so you could still do what you’re talking about.

And just for the fun of it, if I were going to attach conversations to certain tiles, I’d probably create a separate table just for that - here’s a very simplified example:

[lua]

local conversations = {

[114]={“You’re not a queen of Narnia!”, “Avast there, landlubber!”},

[229]={“It’s always winter and never Christmas. *sob*”, “Tumnus has been turned to stone!”}

}

[/lua]

Now when the player is walking around I can check for whether certain places (tiles) have conversations that can be used:

[lua]

if conversations[playerTile] then

  local lines = conversations[playerTile]

  – do some talking thing here

end

[/lua]

So they’re “loosely attached” to the tile – which means it’s probably going to be easier to change things later on. Mess with the tile code without affecting conversations; make the speech tree better without breaking the tile stuff, etc.

Just some ideas.

 Jay

Thanks for the great ideas! :slight_smile: They look super helpful, but I have one question:

With this code would we be able to call the conversations like this:

[lua]

print(conversations[114])

[/lua]

I have also been working on a grid system but I started questioning that. I know that it is customary to add this but I actually usually turn off grids when I am level editing. Here’s the option I was thinking of. The tiles would just snap to the tile next to it (within a chose-able distance) and then it would be able to slide along it and snap to the center of the other tile (with same distance setting) so it’s not necessarily a grid but it adds a way to make things look clean. Which do you guys think would be better?

One thing that you could do would be to make a level editor in Corona. This would probably be the easiest because you’re probably pretty familiar with it’s environment. I think you should make your own anyways because you’re going to need to store info like conversations and story locations in characters (in the game objects). This level editor could then export the level data to a .text file which you could just copy out of the app on your computer into another game If you find a level editor that lets you do all that then that’s probably the best tool. If you are interested in creating a level editor in Corona SDK I would be more than happy to help! I have been wanting to do this for a while :slight_smile:

As for just creating an 8x8 tiled map you could place each image manually or create a “for loop” that will place these in a grid (only useful if they’re the same image).

Tell me if you want me to go into more depth with either of these  :smiley:

Tell me if you want me to go into more depth with either of these  :smiley:

I would, in fact, really appreciate some help! I started this project just to see how I could make such a game, but now I’m much more interested in it.

I’m not sure how to make a level editor in Corona, I suppose it’s a script that places one block after the other to make a map, but I don’t know how to “export the level data”. 

Also, should I setup a repository (GitHub or so) so that we can share the code?

There’s actually an OSS tile map loader being built at the moment - http://forums.coronalabs.com/topic/29681-tiled-map-engine/

C

Yea a github repository would help, but as Caleb said, there is a tiled loader being made. Do you still want  to make your own? 

Btw what do you mean by a “script that places one block after the other”? Wouldn’t you want it so you placed the tiles yourself and then you could edit the properties of individual tiles if you wanted? 

AS, it sounds like you’re thinking of a level editor such as Gumbo, while Zoske is thinking of a level editor like Tiled. The former allows you to place images wherever you want, the latter is for making tile-based games such as the 2D Mario games (and a zillion others).

The “script that places one block after the other” is what a tiling engine does – takes a block of data such as this:

[lua]

      data = {

        39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

        39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

        39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

        39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

        39, 0, 0, 0, 0, 0, 38, 39, 39, 39, 39, 39, 39, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

        38, 0, 0, 0, 0, 0, 39, 39, 39, 39, 39, 39, 39, 39, 0, 0, 0, 0, 0, 0, 0, 38, 39, 39, 38, 0, 0, 0, 0, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 45, 39, 39, 39, 39, 39, 39, 39, 0, 0, 0, 0, 0, 0, 0, 39, 39, 39, 39, 0, 0, 0, 0, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 39, 39, 39, 39, 39, 39, 39, 39, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 38, 39, 39, 39, 39, 39, 39, 38, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0,     

      }

[/lua]

…and places the tiles in the correct spots to make this:

phasetanklvl02.png

Okay, that data was just for placement of the walls (and I chopped most of it out to save space here), there are other layers that put in floors, crates, walkways, etc. But you get the idea.

 Jay

Ooh I get it now. I thought it might be easier if it created a new table for each tile so that it would be able to store properties like conversations. Here’s what this might look like:

[lua]

level1 = {

       tile1 = {image = “image.png”, x = 100, y = 100, lines = “Hello! Welcome to narnia!”}

}

[/lua]

This would also make it easy to read the level code and edit it.

And with this it would do what you were talking about where it would run through all the tiles and place them.

Yeah, being able to attach things like conversations to a tile would be nice. With Tiled you can specify properties per tile so you could still do what you’re talking about.

And just for the fun of it, if I were going to attach conversations to certain tiles, I’d probably create a separate table just for that - here’s a very simplified example:

[lua]

local conversations = {

[114]={“You’re not a queen of Narnia!”, “Avast there, landlubber!”},

[229]={“It’s always winter and never Christmas. *sob*”, “Tumnus has been turned to stone!”}

}

[/lua]

Now when the player is walking around I can check for whether certain places (tiles) have conversations that can be used:

[lua]

if conversations[playerTile] then

  local lines = conversations[playerTile]

  – do some talking thing here

end

[/lua]

So they’re “loosely attached” to the tile – which means it’s probably going to be easier to change things later on. Mess with the tile code without affecting conversations; make the speech tree better without breaking the tile stuff, etc.

Just some ideas.

 Jay

Thanks for the great ideas! :slight_smile: They look super helpful, but I have one question:

With this code would we be able to call the conversations like this:

[lua]

print(conversations[114])

[/lua]

I have also been working on a grid system but I started questioning that. I know that it is customary to add this but I actually usually turn off grids when I am level editing. Here’s the option I was thinking of. The tiles would just snap to the tile next to it (within a chose-able distance) and then it would be able to slide along it and snap to the center of the other tile (with same distance setting) so it’s not necessarily a grid but it adds a way to make things look clean. Which do you guys think would be better?