Mirrored game map files

edited October 2009 in General Chat
Something I've been wrecking my brain with for a bit today, why do you make map files mirrored for games? The only thing I can come up with is that you would scan the file before you use it to look for errors in it and allocate sufficient RAM (hence avoiding hardcoded limits). Reading it from the back would be faster after that then reading it forward again as you don't have to worry about limits (you just look for the beginning of the file) and you don't have to move the filepointer to the top again.

But that doesn't explain why for instance sprite files are not mirrored, so while I'm rather sure the above thing probably would save some time (not all that much though) it doesn't quite explain why the files are mirrored, anyone know? :)

Comments

  • edited October 2009
    Huh?
    :confused:

    You'd have to give some specifics about what you are talking about for people to have an idea... And Mirrored can have a few interpretations as well...

    In general however reading a file backwards will not be efficient - moving the file pointer is almost free but reading backwards you will have to do so after every piece of info you pull in.
  • edited October 2009
    Right, I'm aware of that :) To elaborate on the topic:

    Most games which have tile based maps have a map file which consists of a colour coded version of the map, a river can be a blue pixel and land can be a red green pixel while for instance a forest tile can be a purple pixel. Most of these map files are mirror images of how the data is presented in the game (up is down and left is right). I've been trying to figure out why you would do it like this instead of having the map be in the file as it is in the game. My suggestion is that you read the file once first in order to scan it for inaccuracies (and allow the game to allocate sufficant ram for the map, in order to avoid having to store that data somewhere else or in hard coded limits) to make sure it's legal input and then to save time you read the file backwards as then it will be correct in the game.

    But as I pointed out the speed increase doing it like that wouldn't be very big, so I'm curious if there is a better reason to do it like that, then what I suggested.
Sign in to comment in this discussion.