A challenge with tiles..

SGDK only sub forum

Moderator: Stef

Post Reply
McValdemar
Newbie
Posts: 2
Joined: Fri Mar 20, 2020 6:59 pm

A challenge with tiles..

Post by McValdemar » Thu Mar 26, 2020 10:17 am

Let's say that i have an image, which size multiple of 8 where I want to store all my tiles.
For instance 320x320. That imagine contains 1600 tiles. (I know the limit of 1310, this is just for example).

But in the game each bakground element (t1, t2, t3, ...) made up of 5x5 tiles, as I splitted the image.

Image

1) How can I load all at once and then refer to each tile for drawing?

2) Is there a way to have an array used in the resources file so, even if I have different graphics files, I can load in ANIM[1], ANIM[2], etc... ?

Miquel
Very interested
Posts: 489
Joined: Sat Jul 30, 2016 12:33 am

Re: A challenge with tiles..

Post by Miquel » Fri Mar 27, 2020 11:12 pm

Let’s first agree on what’s the situation: as I understand you have a map, a 2D matrix, where each element is a metatile of 5x5 tiles. Is that correct?
Something like this:

struct Tile
{
int indexOfTileOnVRAM;
int colisionResponseIndex;
};

struct Metatile
{
Tile tiles[ 5 ][ 5 ];
};

const Metatile metatiles[ “whateverNumberYouNeed” ] ={ {},{},… };
int g_map[ 320 ][ 320 ]; // Each element is a index that points to the array of metatiles

First thing that pops to mind is the convenience of always using number belonging to the power of 2.

Is that the precise structure are we talking?
Help. Spanish TVs are brain washing people to be hostile to me.

Post Reply