Tiled map saving optimization

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Kros
Chaos Rift Regular
Chaos Rift Regular
Posts: 136
Joined: Tue Feb 24, 2009 4:01 pm
Current Project: N/A
Favorite Gaming Platforms: PC, Playstation/2/3
Programming Language of Choice: C++
Location: Oregon,USA
Contact:

Tiled map saving optimization

Post 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.
Last edited by Kros on Mon Mar 16, 2009 3:31 am, edited 1 time in total.
Isaac Asimov wrote:Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
YouTube Channel
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Tiled map saving optimization

Post 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
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
User avatar
Kros
Chaos Rift Regular
Chaos Rift Regular
Posts: 136
Joined: Tue Feb 24, 2009 4:01 pm
Current Project: N/A
Favorite Gaming Platforms: PC, Playstation/2/3
Programming Language of Choice: C++
Location: Oregon,USA
Contact:

Re: Tiled map saving optimization

Post 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.
Isaac Asimov wrote:Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
YouTube Channel
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Tiled map saving optimization

Post 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.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Re: Tiled map saving optimization

Post 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)
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Tiled map saving optimization

Post 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?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Re: Tiled map saving optimization

Post 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.
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: Tiled map saving optimization

Post 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.
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Tiled map saving optimization

Post 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 :)
Image
Post Reply