A question about drawing backgrounds from tilesets

Post Reply
zelbo
Posts: 11
Joined: Tue Feb 10, 2009 6:23 am

A question about drawing backgrounds from tilesets

Post by zelbo » Mon Apr 13, 2009 10:47 pm

I seem to remember reading that even though backgrounds get broken into tiles with grit, you can't just make an array and draw your background (forest, forest, grass, water...). I'm trying to make a rogue-like and need to draw dynamic backgrounds, so would i need to assign a vram bank as my background drawing board and stamp sprite tiles all over it then copy it as a background, or just use sprites for my map tiles and draw it all on the same layer as my character and npcs?

Pete
Posts: 18
Joined: Wed Jan 28, 2009 9:12 pm

Re: A question about drawing backgrounds from tilesets

Post by Pete » Tue Apr 14, 2009 2:22 am

I think you might want to take a look at the all_in_one example. In R25 it's located under examples\nds\Graphics\Backgrounds\all_in_one

ex-peluo
Posts: 19
Joined: Wed Apr 15, 2009 10:44 pm

Re: A question about drawing backgrounds from tilesets

Post by ex-peluo » Fri Apr 17, 2009 12:34 am

To draw dynamic backgrounds you can save an bidimensional array were store the map information. Every element in the array points to a portion of tiles. Think you want to draw a 1024*1024 background but DS screens are 256*192. Every tile has 8*8 pixels, and a map so your array must have 128*128 elements(1024/8). But this array is not allocated in Vram, it is in the Ram. So when you want to draw the backgroud you must do this
1.-Calculate the position of the upper left corner on the screen in the array
2.-From this position get the 32*24 ( (256/8) * (192/8) ) elements in the array
3.-Copy this elements to Vram in the position you have the map for this background

This three steps have a lot of work, but this is mi idea to make a dynamic bg.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests