[Tutor] Snakes and Ladders

James Newton jnewton at fuelindustries.com
Fri Jan 4 17:29:01 CET 2008


Hi Python People!

I've recently started learning Python in order to create educational
content for the One Laptop Per Child project:

  <http://www.laptop.org/en/vision/index.shtml>

The first application I'm working on is a game of Snakes and Ladders, to
help younger children understand the concepts of counting and placing
numbers in the right order.

You can find a first draft of the game here:

  <http://olpc-dev.fuelindustries.com/snakes_080104.zip>

To play, click on the dice to obtain a number, then click on the board
squares in the right order.  When you've counted up to the number on the
dice, you'll need to click on the dice again to continue.

I'm looking for help with a number of issues (I'll treat each of the
issues in a separate thread).  To start with what I hope will be an easy
one:

***

I'm importing a graphic named Counter_1.png for the counter.  I'd like
its background to be transparent, using the PNG's built-in alpha
channel.

As this is for the OLPC laptop, where every electron is precious, I want
to load the minimum number of modules to have the minimum processor
overhead.  What is the cheapest way (in terms of RAM usage and CPU
cycles) to display a PNG image with alpha-transparency?
  
I am aware of the VisionEgg demo at...
  <http://visionegg.org/svn/trunk/visionegg/demo/alpha_texture.py>
... but I am concerned that this would be overkill for a simple 2D
application: VisionEgg requires a mini-series of other modules before it
will work.

Or should I forgo alpha-transparency and simply use pygame's
image.set_colorkey(), which will give me a pixelated edge to the
transparent parts of the image?

***

Thanks in advance,

James   


More information about the Tutor mailing list