Generating dynamic backgrounds

Post Reply
hassifa
Posts: 15
Joined: Thu Jul 16, 2009 2:22 am

Generating dynamic backgrounds

Post by hassifa » Wed Jul 22, 2009 1:21 am

I have looked through the libnds forums, trying to find an answer to my current problem, and i have only seen it touched upon. What i am looking to do is to generate a landscape based on a bi-dimensonal array that is read in at run time. I know that the display is made up of 8x8 tiles, and that i need to calculate the 32x24 tile are that is going to be displayed as the background from the map array. I have some loose ideas about how i want to implement it and i will say now.

I want the landscape of the area to be in the BG3 layer. Then any objects that could be manipulated would be in the BG2 layer. (eg doors, trees, stones, bridges over water). I would have several 2D arrays, or a 3D array to hold each layer, aswell as a movement layer for where the player is able to move to / or interact with. The maps can be read in through outside files at the start of the program, and called upon when needed.

The only problem is that i am unsure about how i would create the tiles themselves, and then load each tile into the game itself. If anyone has any resources or guides about this, i would be tankful for providing them, but i will say that i am using libnds, and not PALib, so im not sure how helpful any resources related to that would be.

I have looked at the all_in_one example, and while it does have some helpful methods about displaying the background, it is not entirely what i want to do.

StevenH
Posts: 133
Joined: Sun Feb 22, 2009 7:59 pm

Re: Generating dynamic backgrounds

Post by StevenH » Wed Jul 22, 2009 9:04 am

Unfortunatly there is no best way, but there are a couple of ways I can think of right now:

1) Use your pixel manipulation package to draw the entire map, and then use grit to convert the map into tiles
2) Use a map editing application like mappy, or write your own.

Either way you will have to design your graphics in a pixel manipulation package and convert them using grit.

IMHO:

The first way is the easiest if you are only using one level backgrounds, but you have to be very good at sticking to an 8x8 sub tile (as long as your tiles are multiples of 8x8 you will be fine), and try to keep your tile count down below the maximum allowed at your colour depth (1024 for 16, 512 for 256 colours).

Using a map editor would be the best for multi-layered backgrounds, Again, design your tiles in a pixel manipulation package and then import them into your level editor, your level editor should then be able to export the level in a format that is suited towards your level's layout, and then it's just a case of loading in the data as and when you need it.


I use the term pixel manipulation package instead of paint package as you will want more control over your pixels colour than what most paint packages provide. In this respect I sugeast usenti from Coranac, it looks like MS paint, but it's aimed more for the DS palette and it also uses guide marks for the 8x8 tiles.

The correct file layout for your level's will depend on their orientation, it's no good saving a horizontal level in a row by row format, as you will be doing some major jumps around the data, where as if you store your map data in a column by column, then it's a simple case of copy the next 24 tiles into memory, and it's even faster if you also rotate the background layer by 90 degrees as you will then just be doing a dmaCopy when you need more data in the map buffer.

hassifa
Posts: 15
Joined: Thu Jul 16, 2009 2:22 am

Re: Generating dynamic backgrounds

Post by hassifa » Wed Jul 22, 2009 9:12 am

Following the examples in the all-in-one folder, i was more looking into the ability to use an array to create the maps. The only problem i have, is organizing the 8x8 tiles into an order, the grit rules associated with it, and then the correct way to reference them. I have played around with creating the specific tile arrays in the program itself, as well as the palette, and then i was able to reference them correctly, but i would like to try and create the pngs of the tiles that i want, so i dont have to hard-code the tiles themselves into the program. Also that way, i would easily be able to store maps in external files and load them when needed.

hassifa
Posts: 15
Joined: Thu Jul 16, 2009 2:22 am

Re: Generating dynamic backgrounds

Post by hassifa » Tue Jul 28, 2009 1:37 pm

Just a quick update. I have been playing around with the pixel editor mentioned earlier, and while it looks good, i dont know of any good map editors to work in conjunction with it. Would some people like to give examples of the program they use to create maps for their games? I tried looking up one called the perm-editor, but i dont think i had the correct website for it.

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: Generating dynamic backgrounds

Post by vuurrobin » Tue Jul 28, 2009 3:19 pm

hmm, the link to perm editor that I have seems to link to a removed website. maybe the project stopped...
here is the link if your curious:

http://pernedit.com/index.php?title=Main_Page

anyway, some tilemap editors you may want to try out are Tiled:
http://mapeditor.org/

and Mappy:
http://www.tilemap.co.uk/mappy.php

StevenH
Posts: 133
Joined: Sun Feb 22, 2009 7:59 pm

Re: Generating dynamic backgrounds

Post by StevenH » Tue Jul 28, 2009 7:44 pm

vuurrobin / hassifa,

IIRC Dovoto was attempting to get the perneditor site back up and running, but was having some issues getting the site back up, not sure if he's managed or not.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest