mjocean / PyProcGameHD-SkeletonGame

The current HD VGA Fork of PyProcGame (w/ HW Accel) + SkeletonGame to accelerate new game development
http://pinballprogramming.com
MIT License
14 stars 8 forks source link

SkeletonGame can call a delayed handler on a stopped mode #27

Open clempo2 opened 1 year ago

clempo2 commented 1 year ago

This test case demonstrates SkeletonGame can call a delayed handler on a stopped mode if the mode was stopped within the same tick cycle. See https://github.com/clempo2/SkeletonGameDMD/commit/a3e6b6129a625f0b3e0ea637c872c1e3608c7a5b and https://github.com/clempo2/SkeletonGameDMD/commit/e0c45fe79090792e96685f1d2432d8dd7f69b078 for a possible solution.

from procgame.game import Mode
class DemoStop(Mode):
    def mode_started(self):
        self.delay(name='delay1', event_type=None, delay=0, handler=self.delay1)
        self.delay(name='delay2', event_type=None, delay=0, handler=self.delay2)

    def delay1(self):
        self.game.modes.remove(self)
        print 'DemoStop delay1'

    def delay2(self):
        self.game.modes.remove(self)
        print 'DemoStop delay2'