[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] map format




Am 19.12.2006 um 20:13 schrieb Marius Gedminas:

On Tue, Dec 19, 2006 at 06:59:21PM +0100, Farai Aschwanden wrote:
I wanted to use such a system too, but 2 points stopped me using it:
1. Its restricted to the charset (well 256 chars is quite a lot)

You could use pairs of characters. Or triplets, or whatever.
=> Lol, you absolutely right. That would easy work. Was a long day for me today, brain away...

2. Interprete char signs that way can be expensive:
if "$" then print image x
if "*" then print image y
if ....

Don't do that. Use a dictionary to map from characters to whatever you
want (images, integers, tile objects) on load time. That's what Jasper
did:


symbolToTerrain = {
  '_' : Plains,
  '@' : Fertile,
  '+' : Desert,
  '^' : Mountains,
  '*' : Hills,
  '$' : Forest,
  '%' : Water,
  '~' : River,
  '&' : WideRiver,
  '=' : Roads,
  '#' : Bridge,
  '!' : Cliff,
}

Besides, you should measure the actual code before assuming it will be too expensive.
=> Having the image names to be displayed makes sense...


Marius Gedminas
--
I would suggest re-naming "rmbdd()". I _assume_ that "dd" stands for "data
dependent", but quite frankly, "rmbdd" looks like the standard IBM "we
lost every vowel ever invented" kind of assembly lanaguage to me.
-- Linus Torvalds
:)