[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Hotspots(long) was Re: Introducing Pyzzle



On Thu, 28 Jun 2001, Andrew Jones wrote:

> 
> Since I'm new to pygame and game developing I thought id ask you how to go 
> about coding Myst style interface. Which really just is lots (100s) of pics 
> with there own hot spots and some simple logic for the puzzles. That's a vast
> over simplification, you have all played Myst so you know what's involved. 
> Any ideas?
> 

Hi Andy, pygame,

I have a library that provides very nice hotspot support for pygame and SDL.  It's about 4-6 weeks away from my initial public release though.  This library(mousetrap) builds masks for capturing mouse events.  It can build them from SDL surfaces using the surface's colorkey information, and has support for non-rectangular mouse masks.  Most of the processing occurs in a c library which will be made as a shared library for release, along with a separate package that provides python support for using these masks and support for using pygame Surface objects(really just using the SDL surface).  This library basically run length encodes the mask data into a collection of linked lists, so every pixel from the surface is accounted for(without really enormous memory consumption).  Each surface mask created is given an id, so using the id one can grab a reference to the object that the surface mask corresponds with.  Mousetrap also handles animation well, it's much faster than I personally expected.

So, here's the current status of things I want to do before public release:
z order:  the bare minimum has been done in the c library for z order support in the python bindings.  I am implementing the initial z order support in python as I wanted to actually get something working on a reasonable timeline first, and to explore the problem domain in something easier to work with than c.  As soon as the z order works in python I plan on moving it into a c implementation and providing python bindings so it's a lot faster.  I think I'm on to the last problem in my python implementation and that I will be able to have it working this evening.  I can't guarantee that though, I am not sure what other issues will arise until I get the ones I can see working.  I need z order to support removing on-screen entities non-destructively and animation.

id system: this is also very minimal.  Every time an id is requested, a global (in the mousetrap)unsigned int is incremented for the next id.  There is currently no support for reusing ids, and when this int wraps things will get very nasty.  I have not yet designed this bit so I'm open to suggestions.  I'm tenatively thinking about doing this the same way unix process ids are doled out and recycled.  

GNU autotools: I'm partway through the autotools online book.  I need to use autotools for the mousetrap c library.  This should be fairly straightforward and has minimal dependancies.

Python distutils: for the python bindings to mousetrap.  I know nothing about this yet.  Currently pymousetrap builds with my minimal(very) mousetrap makefile and is statically linked with the mousetrap c object files.  The resulting shared object file is what the python wrappers use to create and manage the mousetrap python types.  The python modules and python wrappers are fairly ugly and not very elegant right now, more of a prototype so I can explore the domain better in an effort to produce something of higher quality and should be considered prototype only material.

Documentation: yeah, I need to do this.  I have docstrings for the C functions that are exported to the python module.

If anyone out there is interested in using/helping with this with the caveats listed above(and below) then please feel free to drop me a line.  I don't really want to drop source to anyone until I can get the z order working (hopefully tonight) and the licensing information slapped in there(most likely LGPL).  And even then, I only have support for building the python version of the library and a minimal linux makefile(tested using python 2.0.x and libsdl 1.2.x).

Thank you for reading my run-on blather,
-b


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org