Page 1 of 1
Tiled map saving optimization
Posted: Mon Mar 16, 2009 2:57 am
by Kros
Hey all,
So, as seems to be the theme these days, I'm doing a little 2D RPG. 32x32 tiles, all that cliche stuff. I have a question about how my maps could be optimized. (right now, this is just for the editor but, most (all) of this will probably be shared with the game as well)
Right now I have a tile struct that has all the necessary data for each tile that needs to be drawn, and then my map is just a 2D array of these tiles. The array ends up having about 768 elements with the way I chop the map up right now.
Code: Select all
//consts
const int WINDOW_WIDTH = 1024;
const int WINDOW_HEIGHT = 768;
const int TILE_SIZE = 32;
const int MAX_TILES_WIDTH = WINDOW_WIDTH / TILE_SIZE;
const int MAX_TILES_HEIGHT = WINDOW_HEIGHT / TILE_SIZE;
//...snip...
Tile map[MAX_TILES_WIDTH][MAX_TILES_HEIGHT]; //32 * 24 = 768
So, right now this isn't scrolling at all, and the maps/levels are pretty tiny. I want to be able to have much bigger maps than this, and then scroll with the screen width/height being about 1024/768 or so.
Is this an okay way to do this? Can I optimize it somehow with a different data structure? Is 768 not a very big # of elements and I'm just thinking it is because I haven't been exposed to large(r) amounts of data before?
Any input is appreciated.
Re: Tiled map saving optimization
Posted: Mon Mar 16, 2009 3:11 am
by MadPumpkin
Kros wrote: Is this an okay way to do this? Can I optimize it somehow with a different data structure? Is 768 not a very big # of elements and I'm just thinking it is because I haven't been exposed to larg(er) amounts of data before?
actually the perenthecies should wrap the letter 'r' not 'er' but whatever lol
and what the hell is with the last '?', was that last thing a question or a statement?
YES is is an ohkay way to do this, but thats only if you want it like this, when i used to make flash games i made some things only one screen( no scrolling at all ), and some scrolling. it doesn't really matter.
FOR EXAMPLE:
Legend of Zelda: Link to the Past
has not a lot of scrolling but a, hell of an amount of diffent pages( screens, et cetera ), where it shows what your looking at
WHERE AS:
Pokémon
is almost entirely scrolling ( one page but viewing small sextions at a time by moving page/screen/et cetera )
besides im sure 700-sixty-some-other-number is better then my friend James' 7000-something elements in his map lol
Re: Tiled map saving optimization
Posted: Mon Mar 16, 2009 3:31 am
by Kros
MadPumpkin wrote:actually the perenthecies should wrap the letter 'r' not 'er' but whatever lol
You're right, editing.
and what the hell is with the last '?', was that last thing a question or a statement?
Read it again, it was a question.
YES is is an ohkay way to do this, but thats only if you want it like this, when i used to make flash games i made some things only one screen( no scrolling at all ), and some scrolling. it doesn't really matter.
FOR EXAMPLE:
Legend of Zelda: Link to the Past
has not a lot of scrolling but a, hell of an amount of diffent pages( screens, et cetera ), where it shows what your looking at
WHERE AS:
Pokémon
is almost entirely scrolling ( one page but viewing small sextions at a time by moving page/screen/et cetera )
I know the scrolling is okay, I'm just unsure of whether or not the way I'm handling my map saving is okay.
Re: Tiled map saving optimization
Posted: Mon Mar 16, 2009 3:22 pm
by MarauderIIC
Try dumping your map class data into a binary file. In C++,
http://www.codersource.net/cpp_file_io_binary.html .
Also you can "optimize" your saving by like, writing a # before a 0 that says how many times 0 is repeated, or something.
Re: Tiled map saving optimization
Posted: Tue Mar 17, 2009 9:52 am
by Moosader
MadPumpkin wrote:
Pokémon
is almost entirely scrolling ( one page but viewing small sextions at a time by moving page/screen/et cetera )
Sections* :P
For Pokemon, though, there are separate maps that are loaded in when you get close enough to the edge of one map (you'll notice a slight pause when it loads in a new map, for the GB versions anyway)
Re: Tiled map saving optimization
Posted: Tue Mar 17, 2009 3:54 pm
by dandymcgee
LusikkaMage wrote:
For Pokemon, though, there are separate maps that are loaded in when you get close enough to the edge of one map (you'll notice a slight pause when it loads in a new map, for the GB versions anyway)
Just curious, how did you find this out?
Re: Tiled map saving optimization
Posted: Tue Mar 17, 2009 6:16 pm
by Moosader
Okay well I didn't research it, so I don't know for sure, but I think it's pretty obvious. Especially for a Gameboy game where memory is limited.
Re: Tiled map saving optimization
Posted: Fri Mar 20, 2009 1:47 am
by Arce
dandymcgee wrote:LusikkaMage wrote:
For Pokemon, though, there are separate maps that are loaded in when you get close enough to the edge of one map (you'll notice a slight pause when it loads in a new map, for the GB versions anyway)
Just curious, how did you find this out?
When you're a coder, you will notice that you begin to wonder how things were implemented as you play through games. Often you find obvious things jump out, while others you can just speculate.
As for streaming levels close to the map, I'd have to take a look at the GB game again, but I really wouldn't doubt it. It sounds about right.
Re: Tiled map saving optimization
Posted: Fri Mar 20, 2009 11:11 am
by eatcomics
Arce wrote:dandymcgee wrote:LusikkaMage wrote:
For Pokemon, though, there are separate maps that are loaded in when you get close enough to the edge of one map (you'll notice a slight pause when it loads in a new map, for the GB versions anyway)
Just curious, how did you find this out?
When you're a coder, you will notice that you begin to wonder how things were implemented as you play through games. Often you find obvious things jump out, while others you can just speculate.
and if you absolutely can't figure out how they did something you go to a forum and ask, right after you've done a google search for the info of course