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

Re: [pygame] map format



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.

> 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.

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

Attachment: signature.asc
Description: Digital signature