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

[pygame] Experiments with numeric for tile generation



I'm a big fan of Megazeux ( http://www.digitalmzx.net
) which is a game-making program based on ASCII
character graphics. The main advantage of using it
over technically superior solutions is that it makes
graphics and gameplay logic very easy - you have 2
colors out of 16 available for each 14x20 tile* and
everything aligns to the tile grid, so collisions are
easy.

The other day I thought it would be fun to see if,
using Pygame and Numeric, I could take this approach
of "severe graphical limitations that make things
easier" and expand it just a little bit. You can see
the result here:
http://people.ucsc.edu/~jhofmann/tiles.py

What I did is to allow each tile to use a palette of
16(rather than 2) colors, with an infinite number of
palettes allowed onscreen. At a tile size of 20x20,
there's very little that can't be done artistically,
and with the multiple palettes, swapping them could be
used for cool effects just like in the Old Days :)

The main problem with this implementation is
performance; doing it in real-time is just too slow.
So instead the program caches every possible tile and
palette combination once. This takes up a decent chunk
of time and memory(the demo allocates 512 tiles x 6
pals, even though it uses only 2 of the tiles. It
starts in 10-15 seconds on my Athlon 64 2800+ and uses
about 15mb) but once it's running every tile can be
blit directly from memory, so the only bottleneck is
blit speeds. I might look into OpenGL for that...

I might expand this into a Megazeux-like program in
the future; there is already some extraneous code in
the demo for the beginnings of a tile editor. But I
thought people might be interested in this kind of
graphical approach. It also shows a use of Numeric for
graphics :)

* (There are now "Super MZX" modes and "sprites" that
break the rules to let you overcome some of these
limitations, but they're complicated hacks and hardly
anyone really bothers with them.)

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com