Sprites vs. Tiles rendering

SGDK only sub forum

Moderator: Stef

Post Reply
Zontar
Very interested
Posts: 55
Joined: Fri Oct 21, 2011 8:58 pm

Sprites vs. Tiles rendering

Post by Zontar » Sun Jun 16, 2013 12:49 am

I've noticed a row-major/column-major design detail that's given me pause when thinking about future implementations.

As the document says, the VDP draws plane tiles in row-major order and sprites in column-major order. However, my immediate concern is, what is the recommended way to use the same tile set for both sprites and plane tiles?

Here is a concrete example. In my game (a fangame of the original Sega Swirl puzzle) I have a board that looks like this:

Image

Initially I was going to use sprites so that swirl disappearing can be animated, however, I realized that this would permit a board size of no larger than 9x8 (72 swirls + cursor). So now I've decided to use a hybrid approach: render static swirls as tiles, and then use sprites of the same swirl graphic to perform animations. The obvious problem here is that tile data can only be loaded into VRAM one way or the other, unless you want to do duplicates. So depending on what you want to use the specific graphics for, it appears that's the way the tiles have to be loaded in. Since they are already loaded in as tiles, they won't display properly when drawn as sprites.

So the way I see things, I have several options here:
  1. For each graphic, define separate constants for sprite and plane graphics, the difference between each being row-major and column-major order. Load both sets of the same graphic in different places and use the appropriate locations in the appropriate settings.
  2. Load a single set of tiles into the VDP, but in differing orders. This would require a custom VDP_loadTiles method.
  3. Load tiles in column-major (sprite) order and use a custom method to display the tiles one 8x8 block at a time on the plane.
Am I missing a better way? How have any of you addressed the case of requiring the same graphic for plane tiles and sprites?

Mask of Destiny
Very interested
Posts: 616
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Sun Jun 16, 2013 5:13 am

There's no set order for displaying tiles in backgrounds. It's all controlled by the tile map. I'm not terribly familiar with SGDK, but I imagine one of the other folks can give you some advice about generating a proper tile map with it.

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Re: Sprites vs. Tiles rendering

Post by r57shell » Mon Jun 17, 2013 1:34 am

Zontar wrote:As the document says, the VDP draws plane tiles in row-major order and sprites in column-major order.
First = order of entries in map table. But they can have any value.
5,1,7,2,1...
cell 0: tile 5
cell 1: tile 4
cell 2: tile 7
cell 3: tile 2
cell 4: tile 1
...
cells from left to right = row-major order.

Second = order of tiles in VDP for sprite. For example, sprite with "name" (first tile) = 5, with size of 3x4 (WxH):
5 9 13
6 10 14
7 11 15
8 12 16
here, column-major order.
Image

Post Reply