gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > How do you program sprites with 140x140 in size of bigger?

#26446 - LOst? - Wed Sep 15, 2004 11:49 pm

Do you know how this technique is working? You use a background map like this:
http://www.logotypes.se/tmp/map1.png

To produce this 3D falling doorway:
http://www.logotypes.se/tmp/map1_1.png
http://www.logotypes.se/tmp/map1_2.png

And you'll use a background map to like this:
http://www.logotypes.se/tmp/map2.png

To produce the biggest enamy I have ever seen:
http://www.logotypes.se/tmp/map2_1.png

Of course the small parts like the eyes and nose and shoes are in OAM. But how do you make that background map turn into a 3D brick, and a round body?

And what's this technique called?

#26449 - keldon - Thu Sep 16, 2004 12:05 am

By changing the position during in HBlank. It's pretty much the same thing you do in out-run type racing games. Basically of you imaging that circular body as only a set of lines of a certain width, then when drawing each line you adjust the y value of the background layer so that the line with the correct width coloured line is displayed.

You can see that the same display-lines are used repeatedly by comparing the map of the door where the shadow is pretty square, and when it appears in the level where it is stretched.


Last edited by keldon on Thu Sep 16, 2004 12:22 am; edited 1 time in total

#26450 - LOst? - Thu Sep 16, 2004 12:13 am

keldon wrote:
By changing the position during in HBlank. It's pretty much the same thing you do in out-run type racing games.


But isn't it very complex to do a falling 3-D brick like in the screen shot? And why is the map drawn in triangles?

#26452 - sajiimori - Thu Sep 16, 2004 12:27 am

It will take some thought, but hblank effects with a rot/scale bg will do the trick. I guess the art is drawn in that shape to make it scale more gracefully (with less pixelation when scaling up and less dropouts when scaling down). The math for the big door should be similar to regular "mode 7" style, except compensating for the triangular map.

#26453 - LOst? - Thu Sep 16, 2004 12:34 am

sajiimori wrote:
It will take some thought, but hblank effects with a rot/scale bg will do the trick. I guess the art is drawn in that shape to make it scale more gracefully (with less pixelation when scaling up and less dropouts when scaling down). The math for the big door should be similar to regular "mode 7" style, except compensating for the triangular map.


Okay, thanks!

#26454 - keldon - Thu Sep 16, 2004 12:39 am

The falling block shouldn't even be seen as 3d in terms of code. It's just due to the effect of two mapped polygons moving in unison. Again they are not even polygons. It is not that difficult, there are basically 2 variables; top and divider. The divider is what seperates the dark block to the block with lines.

Code:
top = seperator = 80;
VBLstep = 1;
void VBLHandler (){
   // Only do this for 60 VBL's
   while ( VBLstep <= 60 ) {
      seperator = 80 - (80 * 60 / VBLStep);
      top = 80 - (60 * 60 / VBLStep);
   }

}

This basically makes the top move more slowly to the bottom than the seperator, giving the illusion of falling over a distance of 80 pixels.

As for the map being a triangle, as briefly discussed in my previous post (which I edited while you were writing yours). A triangle is used so that every possible line width is available to work with; although some will never be used.

#26455 - keldon - Thu Sep 16, 2004 12:44 am

Oh sorry, my understanding of GBA graphics hardware is not even at beginner level. I only read up about mode 0 (I think it was). And I started typing before your posts appeared too =) - but the top and seperator could still be calculated the same way.

#26456 - LOst? - Thu Sep 16, 2004 1:09 am

keldon wrote:
The falling block shouldn't even be seen as 3d in terms of code. It's just due to the effect of two mapped polygons moving in unison. Again they are not even polygons. It is not that difficult, there are basically 2 variables; top and divider. The divider is what seperates the dark block to the block with lines.

Code:
top = seperator = 80;
VBLstep = 1;
void VBLHandler (){
   // Only do this for 60 VBL's
   while ( VBLstep <= 60 ) {
      seperator = 80 - (80 * 60 / VBLStep);
      top = 80 - (60 * 60 / VBLStep);
   }

}

This basically makes the top move more slowly to the bottom than the seperator, giving the illusion of falling over a distance of 80 pixels.

As for the map being a triangle, as briefly discussed in my previous post (which I edited while you were writing yours). A triangle is used so that every possible line width is available to work with; although some will never be used.


Cool. This is really helpful to see. The falling block is really nicely done because it hasn't any wierd pixels like what you usually see in mode 7 graphics. That's why I like this technique so much.

And I still believe it's made in mode 0, and because of that, the triangle helps making it appear less or closer.

Also I want to point out that the palette is animated so it looks more 3-D.