Beispiel #1
0
    def run(self, room):
        pygame.init()
        debugger.info("turning ON engine...")
        try:
            import psyco
            psyco.full()
            debugger.info("python-psyco module found, performance acelerarion enabled")
        except ImportError:
            debugger.warn("python-psyco module not found, performance aceleration unavaliable")

        self.display.open()
        self.room = room()
        leave = False
        while not leave:
            try:
                self.clock.tick()
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        raise StopEngine()
                    elif event.type == pygame.MOUSEMOTION:
                        event_dict = { "type":MOUSE_MOTION, "pos":self.mouse.position, "obj":self._get_picked()  }
                        debugger.info("MOUSE_MOTION event launched %s" % event_dict)
                        self.room.on_event(event_dict)
                    elif event.type == pygame.MOUSEBUTTONDOWN:
                        self.__process_mouse_button_down( event )
                    elif event.type == pygame.MOUSEBUTTONUP:
                        self.__process_mouse_button_up( event )
                        #self.room.on_event(event)
                    elif event.type == pygame.KEYDOWN:
                        event_dict = { "type":KEY_DOWN, "key":event.key, "mod":"NotImplemented" }
                        debugger.info("KEY_DOWN event launched %s" % event_dict)
                        self.room.on_event(event_dict)
                    elif event.type == pygame.KEYUP:
                        event_dict = { "type":KEY_UP, "key":event.key, "mod":"NotImplemented" }
                        debugger.info("KEY_UP event launched %s" % event_dict)
                        self.room.on_event(event_dict)
                self.__update()
                # Sort the container list by Z axis.
                #self.room.container.sort(key=lambda d: d.position.z)
                # Call update the room
                self.room.update()
                self.room.draw()
                self.mouse.update()
                self.mouse.draw()
                self.display.flip()
            except ChangeRoom, e:
                debugger.info("ChangeRoom exception raised, changing room to %s" % e.__class__.__name__)
                self.room = e
            except StopEngine:
                debugger.info("stopping Engine...")
                leave = True
Beispiel #2
0
    def run(self, room):
        pygame.init()
        debugger.info("turning ON engine...")
        try:
            import psyco
            psyco.full()
            debugger.info(
                "python-psyco module found, performance acelerarion enabled")
        except ImportError:
            debugger.warn(
                "python-psyco module not found, performance aceleration unavaliable"
            )

        self.display.open()
        self.room = room()
        leave = False
        while not leave:
            try:
                self.clock.tick()
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        raise StopEngine()
                    elif event.type == pygame.MOUSEMOTION:
                        event_dict = {
                            "type": MOUSE_MOTION,
                            "pos": self.mouse.position,
                            "obj": self._get_picked()
                        }
                        debugger.info("MOUSE_MOTION event launched %s" %
                                      event_dict)
                        self.room.on_event(event_dict)
                    elif event.type == pygame.MOUSEBUTTONDOWN:
                        self.__process_mouse_button_down(event)
                    elif event.type == pygame.MOUSEBUTTONUP:
                        self.__process_mouse_button_up(event)
                        #self.room.on_event(event)
                    elif event.type == pygame.KEYDOWN:
                        event_dict = {
                            "type": KEY_DOWN,
                            "key": event.key,
                            "mod": "NotImplemented"
                        }
                        debugger.info("KEY_DOWN event launched %s" %
                                      event_dict)
                        self.room.on_event(event_dict)
                    elif event.type == pygame.KEYUP:
                        event_dict = {
                            "type": KEY_UP,
                            "key": event.key,
                            "mod": "NotImplemented"
                        }
                        debugger.info("KEY_UP event launched %s" % event_dict)
                        self.room.on_event(event_dict)
                self.__update()
                # Sort the container list by Z axis.
                #self.room.container.sort(key=lambda d: d.position.z)
                # Call update the room
                self.room.update()
                self.room.draw()
                self.mouse.update()
                self.mouse.draw()
                self.display.flip()
            except ChangeRoom, e:
                debugger.info(
                    "ChangeRoom exception raised, changing room to %s" %
                    e.__class__.__name__)
                self.room = e
            except StopEngine:
                debugger.info("stopping Engine...")
                leave = True
Beispiel #3
0
 def on_talk(self):
     debugger.warn('on_talk() method called. NotImplemented')
Beispiel #4
0
 def on_talk(self):
     debugger.warn('on_talk() method called. NotImplemented')