Reading tiles on map

Post Reply
Derrik
Posts: 63
Joined: Wed Aug 14, 2013 8:28 pm

Reading tiles on map

Post by Derrik » Sat May 24, 2014 12:55 pm

I have a 512x512 background inited with:

Code: Select all

int id = bgInit(0, BgType_Text8bpp, BgSize_T_512x512, 28, 0);
And am then trying to get the tiles so I can write a collision system for a game.

Code: Select all

inline u16 getTile(int id, int x, int y) {
    return bgGetMapPtr(id)[y * (512 / 8) + x];
}
Although this function returns values which are in my map, it returns the wrong ones.

Derrik
Posts: 63
Joined: Wed Aug 14, 2013 8:28 pm

Re: Reading tiles on map

Post by Derrik » Sat May 24, 2014 2:00 pm

I figured it out, each 256x256 block is placed with inverted X and Y coordinates.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests