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

Re: [pygame] Typo in docs?



On Sat, 30 Jun 2001, Pete Shinners wrote:

>> a really handy way to add stuff into the main event loop, and thus avoid
>> making spaghetti of the code (ok, it's quite spahetti-like already, but
>> I'd rather avoid making it more).
>
>
>chackie, feel free to give us/me a report on how well this works
>(or doesn't). i did some simple testing with it, and it all looks
>good, but i'm curious to see how it works in the "real world" also
>be aware that these custom event objects only work for events
>>= USEREVENT. also, the maximum number of evetns SDL handles is
>"NUMEVENTS", which is 32. i've never checked if SDL actually
>works with event numbers bigger than 32, but when i looked at the
>code it seemed like it should, (i'd label it "undefined")

>i'd like the Event stuff to be a clean way to pass events around
>in bigger projects (like yours). but without any real hands-on in
>that area, its hard to know if there's any roughspots.

I've started playing a little with USEREVENT:s, but I'm not exactly sure
as to what I can do with them. Could you please elaborate a little bit
what I can do? Basically I'd like to inherit an Event class and mark it as
a USEREVENT. The I'd internally keep my own event id:s, so that I could
have a lot more (infinite in practice) than the 8 extra allowed by SDL
(USEREVENT=24, max=32). I'd like to do something like this:

import pygame.event

class CustomEvent (pygame.event.Event):
    def __init__ (self, type):
        pygame.event.Event.__init__ (self, USEREVENT, {} )
	self.type = type

    def getType (self):
        return self.type


class SomeEvent (CustomEvent):
    def __init__ (self):
        CustomEvent.__init__ ( 10 )


This is obviously wrong, as it doesn't work. :-) What is the difference
between and reasongin behind the 'dict' and 'keyword_args' parameters to
pygame.event.Event()? I'm a little confused, but it can be attributed to
still lacking Python knowledge.

Is it possible to inherit a class and thus get custom events, and still be
able to feed them to the normal event mechanish using post()?

My own event handling code would of course upon seeing something of type
USEREVENT check the internal type of the event and act upon it. Would even
make it possible to assocate some code with each event to allow the events
themselves to execute something.

Any ideas? Is this possible? If not I can live quite ok with only 8 custom
events, but more would be merrier. :-)

---
--------------------+--------------------------------------------------------
Jan 'Chakie' Ekholm |     Balrog New Media    http://www.balrog.fi/
   Linux Inside     | I'm the blue screen of death, nobody hears your screams

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