Bennu Game Development

English Forums => General => Topic started by: aliasbody on July 15, 2014, 08:48:34 PM

Title: How do you create your maps ?
Post by: aliasbody on July 15, 2014, 08:48:34 PM
Hello Everyone,

I've searched the web and found a lot of ways but didn't find quite saw a perfect one (or am I looking at the right place ?).

My question is, how do you create your 2D maps ? I am looking for a method to create big maps (let's say Zelda one) as well as small maps (like the example game I've posted in the Projects page), and wanted to know what do you use to do that (using only native tools).

I've tried by creating a .txt file and then loading all the tiles separately in the FPG but that don't seem a good solution for big maps.
Title: Re:How do you create your maps ?
Post by: handsource-dyko on July 16, 2014, 07:18:37 AM
You could create a big bitmap, but this has many disadvantages.  Editing is complicated and for the collision detection you need to create a seperate map. I'd recommend to use tiles, much more memory efficient, edit friendly (you can store the references to your tile in an array).


I have done my own map editor for malvado, and due to the way the game works (with big bitmaps) not very straight-foreward in design.
Tilemap editing is much easier and efficient.




Title: Re:How do you create your maps ?
Post by: aliasbody on July 16, 2014, 09:53:56 AM
Quote from: handsource-dyko on July 16, 2014, 07:18:37 AM
You could create a big bitmap, but this has many disadvantages.  Editing is complicated and for the collision detection you need to create a seperate map. I'd recommend to use tiles, much more memory efficient, edit friendly (you can store the references to your tile in an array).

I have done my own map editor for malvado, and due to the way the game works (with big bitmaps) not very straight-foreward in design.
Tilemap editing is much easier and efficient.


Hello, Thank you for the suggestion :)

I was aware of the big bitmap problem, I don't think the editing is complicated since applications like Tiled exist, but editing on the fly really becomes complicate when trying to build a changeable world (like terraria does for example).

I have the idea, correct me if I'm wrong, that the problem with the tiles is the flexibility of the map. So if I want do to something based on squares then the tiles is perfect, but if I want to make something more appealing like having a background and a foreground (front background ?) then I'll had to use bitmaps. Or at least share the two, using two bitmaps one for the back and one for the front (with transparency) and then use the tiles method in order to create the structure of the game.

But here is my question. I've seen that, in terms of memory, BennuGD prefers to have a huge pictures rather than a lot of small pictures. What I've noticed is that, on my Example game (on the Projects page), I have 10 bitmaps of 640x480 with the map, and then I am controlling everything by color of the position of X and Y. The total memory of the game without the FPG containing those bitmaps loaded is 3.4MB-4MB and the memory with those bitmaps loaded is 10.6Mb-11Mb. When loading a bitmap containing all of those bitmaps in one only image, the total memory size is about 4.6Mb-5.1Mb.

When using tiles however (and without any sprite, but only with 16bits colored maps of 20x20), I can fill up a full map and only take something like 0.1Mb-0.2Mb which is perfect.

But here is my two questions :
1 - Is it better to load every sprite separately into a map and then put them in an FPG and use them, or is it better to create a SpriteSheet ?
2 - What about collisions ? How can I do them if the sprites are separate from the bitmap method I was using (map_get_pixel) ? Is there a way to attribute a "color or palette" to the map in order to know, let's say, that the lava is red and the grass is white, then if it is white the user simply keeps on it without falling trough it but if it is red than it takes a hint ?

Thank you in Advance !
Title: Re:How do you create your maps ?
Post by: handsource-dyko on July 17, 2014, 07:24:58 AM
Tilemaps can be very flexible too, it depends on how you implement them. Multi-layer tiles with transparancy is possible. You can create big bitmaps in memory and use map_putxnp or something like that to copy them onto the bitmap in memory. Works fine for the more static backgrounds. For more dynamic parts, you could use sprites.


When it comes to collisions with tiles, you can also use the hardnessmap methode (as a seperate tile layer). Did you know that most 2d games even with multi-layer backgrounds and appealing levels such as rayman, earthworm jim and many others simply used tiles? There no different really them super mario bros 1, but they use more layers, and more tile sets.


1. You can use both, but FPG's are very efficient and conveint.
2. You can use map_get_pixel with tiles as well, if you create seperate "collision tiles" that are hidden from view.
Title: Re:How do you create your maps ?
Post by: aliasbody on July 17, 2014, 10:09:36 AM
Quote from: handsource-dyko on July 17, 2014, 07:24:58 AM
Tilemaps can be very flexible too, it depends on how you implement them. Multi-layer tiles with transparancy is possible. You can create big bitmaps in memory and use map_putxnp or something like that to copy them onto the bitmap in memory. Works fine for the more static backgrounds. For more dynamic parts, you could use sprites.


When it comes to collisions with tiles, you can also use the hardnessmap methode (as a seperate tile layer). Did you know that most 2d games even with multi-layer backgrounds and appealing levels such as rayman, earthworm jim and many others simply used tiles? There no different really them super mario bros 1, but they use more layers, and more tile sets.


1. You can use both, but FPG's are very efficient and conveint.
2. You can use map_get_pixel with tiles as well, if you create seperate "collision tiles" that are hidden from view.

So if I understand it right, on this example

http://ultradownloads.com.br/conteudo/jogos/earthwormjim_02.jpg

The background with the "mountains" (?) is a big bitmap which moves at, lets say, a speed of 5;
The area where the player is could be tiles but in this example it seems also like a big bitmap with an hardnessmap method.
And the players character, the cow, and the fridge in the top are sprites because they need to move and to be interacted.

Did I miss something ? And if the ground isn't a bigmap but a lot of sprites, then it would've needed a lot of them in order to create only this image since 2 tiles repeating.

Thanks once again for the suggestions !

PS : While trying to create the same map using only tiles, I've manage to do it by using a 2D Array with numbers representing the desired area. I was trying to create a function which would take a 2D Array and a FPG and then depending on the number provided would call the same number of the tile in the FPG file (just to same me some time since I could created this 2D Array with "Tiled". But I don't know how to parse a 2D Array into a function... But I'll ask for it in another thread in order for anyone with the same problem to have the solution :) Just to say that this method makes my 10 maps use 0.2Mb-0.3Mb instead of the usual 7Mb-9Mb, which is great :)
Title: Re:How do you create your maps ?
Post by: handsource-dyko on July 17, 2014, 11:48:16 AM
Your observation is quite accurate. The mountains where earthworm jim and the cow stand on are tiles. The collision hardnessmap are probably tiles as well (that's how jazza jackrabbit 2 does it). The background beneath could also be tiles, or a bitmap (either solution is possible).
There are indeed a lot of tiles, but if you examine those games closer, you can see repition. A good example is a sega megadrive game called "mick and mack global gladiators" ( [size=78%]http://www.mobygames.com/game/genesis/mick-mack-as-the-global-gladiators (http://www.mobygames.com/game/genesis/mick-mack-as-the-global-gladiators)[/size] ).


This game was made with a tool called TUME (The Universal Map Editor) [/size][size=78%]http://en.wikipedia.org/wiki/TUME (http://en.wikipedia.org/wiki/TUME)[/size]   [/size][size=78%]http://games.greggman.com/game/tume___the_universal_map_editor/ (http://games.greggman.com/game/tume___the_universal_map_editor/)[/size]


Also, earthworm jim was made with this tool. It was originally developed for the amiga, but was also ported to dos. The software is a bit of an historical artifact though, but it works with dosbox if you're curious to look what those development tools where like.



Title: Re:How do you create your maps ?
Post by: aliasbody on July 17, 2014, 12:24:08 PM
Quote from: handsource-dyko on July 17, 2014, 11:48:16 AM
Your observation is quite accurate. The mountains where earthworm jim and the cow stand on are tiles. The collision hardnessmap are probably tiles as well (that's how jazza jackrabbit 2 does it). The background beneath could also be tiles, or a bitmap (either solution is possible).
There are indeed a lot of tiles, but if you examine those games closer, you can see repition. A good example is a sega megadrive game called "mick and mack global gladiators" ( [size=78%]http://www.mobygames.com/game/genesis/mick-mack-as-the-global-gladiators (http://www.mobygames.com/game/genesis/mick-mack-as-the-global-gladiators)[/size] ).


This game was made with a tool called TUME (The Universal Map Editor) [/size][size=78%]http://en.wikipedia.org/wiki/TUME (http://en.wikipedia.org/wiki/TUME)[/size]   [/size][size=78%]http://games.greggman.com/game/tume___the_universal_map_editor/ (http://games.greggman.com/game/tume___the_universal_map_editor/)[/size]


Also, earthworm jim was made with this tool. It was originally developed for the amiga, but was also ported to dos. The software is a bit of an historical artifact though, but it works with dosbox if you're curious to look what those development tools where like.

It is true that in this picture
http://images.br.sftcdn.net/br/scrn/3349000/3349827/jazz-jackrabbit-2-01-695x535.jpg

We can clearly see the amount of tiles used for the map. But in the next picture, for me, understand what is tile and what's not become difficult :

http://images.br.sftcdn.net/br/scrn/3349000/3349827/jazz-jackrabbit-2-02-695x535.jpg

Of course I know that the same tiles to create the ground used in the first picture are tiles, and well the characters and anything moving bust be sprites, as well as the background must be a big bitmap moving slower than the rest of the map. But still are the carrots tiles or sprites ? Well that would depend if they have interactions or not, or at least if they need to move or not. For example, I can create tiles for a group of stairs and make the player interact with them by climbing, but they are still tiles.

I think I start to understand... But then one more question, those tiles the that never move which are used by the user to just stand and walk (like grass, sand etc..), are assembled before, by hand or using a software, and then loaded in the game as a big bitmap (now I am talking only for more recent games and not for the old 8bits games where I know that those tiles are loaded as the player advances like in Mario), or are they loaded using something like a 2D Array like I am trying to do ?

If it is the first one, then would it be using a lot of resources ? Those images must be loaded one by one no ?
If it is the second one, then they must have separate files just to handle the levels and all those contents no ?

On the other hand, doing something like this :
http://www.gun-lord.com/screens/0450.png

Like this:
http://indiestatik.com/wp-content/uploads/2012/12/STF_apoc.png

Or even like this :
http://indiestatik.com/wp-content/uploads/2012/12/Screen-shot-2012-12-27-at-16.51.29.png

Would have required a lot of different tiles. I don't say that they don't exist, because they may exist. But let's say the dev wanted to create a whole level different from the others, and this level had to be all like the 3 I've sent, then they would have to play a lot with big bitmaps right ?

PS: Thank you for the links, I'll have a close look at that :)
Title: Re:How do you create your maps ?
Post by: handsource-dyko on July 18, 2014, 07:50:10 AM
Most of the examples (except the last one) are likely to be tiles. Some games had very big tilesets. The carrots in Jazz Jackrabbit 2 are also tiles.
I have this game, and it comes with an editor, so I can confirm this. The tilesets for this game are quite comprehensive.

A lot of games would put the tileset itself on a bitmap, load that in, and then copy each grid block to memory (so that you get individual bitmaps in memory). The editors also work this way. They take the tileset bitmap, and since it's a fixed size grid, use a routine that copies bitmap segments of 16x16 pixels to memory. The bennu function map_block_copy can be used for that.
Title: Re:How do you create your maps ?
Post by: aliasbody on July 18, 2014, 09:10:00 AM
Quote from: handsource-dyko on July 18, 2014, 07:50:10 AM
Most of the examples (except the last one) are likely to be tiles. Some games had very big tilesets. The carrots in Jazz Jackrabbit 2 are also tiles.
I have this game, and it comes with an editor, so I can confirm this. The tilesets for this game are quite comprehensive.

A lot of games would put the tileset itself on a bitmap, load that in, and then copy each grid block to memory (so that you get individual bitmaps in memory). The editors also work this way. They take the tileset bitmap, and since it's a fixed size grid, use a routine that copies bitmap segments of 16x16 pixels to memory. The bennu function map_block_copy can be used for that.

Well I guess it's just me missing the terms and thus not understanding quite well all the design concepts. What I don't understand, and I think that this will be solving my understanding problem, is.. Do all the tiles have to be the same size ? I understand that some games can have 16x16 tiles, others with 32x32 and so on, but do they have to be exactly the same size for the engine to take them or can the same map have tiles with different sizes ?

For big objects (like cars just for the background, not like in Metal Slug when you can interact with them), are they usually a new set of tiles of the size of the car but in a different layer or are they respecting the "others tiles size" as well ?

I didn't quite understand how the  map_block_copy works. In the example game I have in the Projects page (updated yesterday to use tiles as you advised), I created a function which would take the input from a 2D Array, then would call corresponding MAP in the FPG file and would simply put it on the screen and "leave", with that the idea was to copy it into the screen and let it there, nothing more. With this the memory consumption drop down from 10.6Mb to 3.8Mb (almost as much as the game only showing a black screen). And then I have another function to put the player and the enemies on the screen. In this case would  map_block_copy be useful ? And if yes on which case ?

Sorry for all those questions, but I am still trying to understand all of the design concepts. I have to say that this is my true weakness.
Title: Re:How do you create your maps ?
Post by: handsource-dyko on July 18, 2014, 10:28:46 AM
Tile sizes are usually the same throughout the entire game. The designers simply make a choice to use 16x16 or 32x32 depending on the artwork and technical restrains. Some systems only supported on or two tile sizes, so the devs had to use that size imposed by the graphics
hardware.


Big objects are simply composed of standard tiles as well. The graphic designers simply devide a big object into A grid and you'll get some unique tiles. Some systems also imposed limitations on sprite sizes, and they used a similair technique. In Bennu, big spites are no problem, they can be any size you want.


You can avoid map_block_copy if you already have an fpg file with individual tiles. Map_block_copy is more intended to copy portions of a bitmap to another bitmap. As it is possible to create fpg's and bitmaps in memory, this can be usefull.
Title: Re:How do you create your maps ?
Post by: aliasbody on July 18, 2014, 10:38:32 AM
Quote from: handsource-dyko on July 18, 2014, 10:28:46 AM
Tile sizes are usually the same throughout the entire game. The designers simply make a choice to use 16x16 or 32x32 depending on the artwork and technical restrains. Some systems only supported on or two tile sizes, so the devs had to use that size imposed by the graphics
hardware.


Big objects are simply composed of standard tiles as well. The graphic designers simply devide a big object into A grid and you'll get some unique tiles. Some systems also imposed limitations on sprite sizes, and they used a similair technique. In Bennu, big spites are no problem, they can be any size you want.


You can avoid map_block_copy if you already have an fpg file with individual tiles. Map_block_copy is more intended to copy portions of a bitmap to another bitmap. As it is possible to create fpg's and bitmaps in memory, this can be usefull.

I think that I start to understand now, the map_block_copy would be good if I used the TileSheet instead of using the sheets in a separate way. But now I have a doubt, is it more memory efficient to use a TileSheet and then use map_block_copy and load a png (for example), or is the FPG optimized to allow the use of several tiles without compromising the memory usage ?

As a more clear example what would be better in terms of memory ?
1: Put 1000 tiles of 32x32 in 1 map each and then port it into a single FPG file which would be loaded at the start.

2: Make the same thing but load them as needed (example dividing the FPG by level or by types of buildings if they require something like 200tiles just to be formed).

3: Make a huge bitmap with all the tiles and use a single FPG

4: Or is it better to use the huge bitmap and then use map_block_copy ?
Title: Re:How do you create your maps ?
Post by: handsource-dyko on July 18, 2014, 12:52:09 PM
Fpg's are conveint. They can have zlib compression, (depending on the application they where created with). I don't know if png's are any better in terms on memory usage (well, if you compare them using the same bith depth).


An fpg is just a container format based on the bennu map format (so if you have 200 small 32x32 bitmaps in them shouldn't really matter compared to a spritesheet png with the same contents). I don't know wich format has more overhead. I don't think it is that critical, maybe splinterGU can tell you wich format is more memory efficient considering the same amount of graphic content.


Generally, I recommend to use a tileset for each level and load them as needed. You then unload the previous tileset first. (bennu has unload_map and unload_fpg functions).
Title: Re:How do you create your maps ?
Post by: aliasbody on July 18, 2014, 01:32:56 PM
Quote from: handsource-dyko on July 18, 2014, 12:52:09 PM
Fpg's are conveint. They can have zlib compression, (depending on the application they where created with). I don't know if png's are any better in terms on memory usage (well, if you compare them using the same bith depth).


An fpg is just a container format based on the bennu map format (so if you have 200 small 32x32 bitmaps in them shouldn't really matter compared to a spritesheet png with the same contents). I don't know wich format has more overhead. I don't think it is that critical, maybe splinterGU can tell you wich format is more memory efficient considering the same amount of graphic content.


Generally, I recommend to use a tileset for each level and load them as needed. You then unload the previous tileset first. (bennu has unload_map and unload_fpg functions).

I think I start to have a clear picture in my head on how to do everything thanks to you :)

I still have 2 questions :
1 - Is there a way to add a color to a map ? Let's say a create some grass, it would be great if the MAP format could accept an RGB input for this tile in especial, that way it could be worked in the game more easily in terms of wall/ground detection for example. I don't know if this exist. I mean I know that the hardness map as a background in memory is the way to go as you already told me (since this would alow (us coders) to understand what can be used as ground or wall and what's not. But maybe it is just a silly idea.. Another solution would have to create something telling that 1,2,4 and 5 (for example) is block and the others not. --- Sorry I didn't remember that you already answered this one :S

2 - I am using fenix-fpg and fenix-map in order to create and work with the FPG and the MAPS, this because I am using Gnu/Linux and couldn't find a good tool (and also because I prefer to work directly with the terminal). So my question is, I didn't found anything similar on BennuGD, does it exist ?
Title: Re:How do you create your maps ?
Post by: handsource-dyko on July 18, 2014, 03:51:59 PM
Unfortunatly there is not equivaliant to fenix-fpg for bennugd (at least not the old fenix 0.84 gui based one). Your best bet would be to use fpedit with wine. Or install a virtual machine with windows. Wine is probably more conveint. However, since you can perform all fpg managment operations with bennu functions, you could also create your own commandline tool. Bennu has functions to work with commandline arguments. It is not so complicated to generate an fpg from graphics in a directory. Some people have made fpg editors with bennu. I have once made a special drawing tool for malvado that works with fpgs.

When I do general fpg editing, fpgedit and smartfpg edit are the tools I use.  Fpgedit is written in freepascal/lazarus, so a potentional linux port could be made. I have contributed to the translations of it. I believe it has a version optimized for use with wine. Forum member DCelso is the author of fpgedit 4.0.
Title: Re:How do you create your maps ?
Post by: aliasbody on July 18, 2014, 03:55:54 PM
Quote from: handsource-dyko on July 18, 2014, 03:51:59 PM
Unfortunatly there is not equivaliant to fenix-fpg for bennugd (at least not the old fenix 0.84 gui based one). Your best bet would be to use fpedit with wine. Or install a virtual machine with windows. Wine is probably more conveint. However, since you can perform all fpg managment operations with bennu functions, you could also create your own commandline tool. Bennu has functions to work with commandline arguments. It is not so complicated to generate an fpg from graphics in a directory. Some people have made fpg editors with bennu. I have once made a special drawing tool for malvado that works with fpgs.

When I do general fpg editing, fpgedit and smartfpg edit are the tools I use.  Fpgedit is written in freepascal/lazarus, so a potentional linux port could be made. I have contributed to the translations of it. I believe it has a version optimized for use with wine.

Maybe my best bet would be to create my own using Bennu or simply continue using the old one.. I still don't get it why they drop the support for it, maybe for the same reason of the License change (indirectly of course).

Well, once again thank you for everything :) I think with all of this from now on I will be able to construct the game I had in mind for years !
Title: Re:How do you create your maps ?
Post by: JaViS on July 18, 2014, 04:39:08 PM
/have you guys tried https://code.google.com/p/smartfpgeditor/?
Title: Re:How do you create your maps ?
Post by: aliasbody on July 18, 2014, 04:49:34 PM
Quote from: JaViS on July 18, 2014, 04:39:08 PM
/have you guys tried https://code.google.com/p/smartfpgeditor/?

It only works under Windows, and I don't use any Proprietary Software (smartfpgeditor isn't but Windows is), so I can't use it for my personal work. I've tested it, it works great and has a clean interface, but he can't open FPG's created by fenix-fpg.