play = PlayState('play', entitysystem) play.activate() # unterschied zwischen transitionTo und activate? # setup StateMachine sm = StateMachine() # sm.start_state = splash # sm.end_state = end sm.setStartEnd(splash, end) sm.addState(play) sm.addTransition(splash, 'x', play) # bei event x #sm.addTransition(play, 'x', end) # bei event x # messenger.subscribe('x'); messenger.subscribe(lambda: sm.handle('x'), "x") sm.activate() #teststates = {}; #teststates['src1'] = {}; #teststates['src2'] = {}; #teststates['src1']['msgX'] = 'destination1x' #teststates['src1']['msgY'] = 'destination1y' #teststates['src2']['msgZ'] = 'destination2z' # enable termination of application from each single state # messenger.subscribe(sm.handle(end), 'end') # game loop while not end_of_game:
def add(entity): messenger.subscribe(entity.draw, "render"); functions.append(lambda:entities.append(entity))
def initialize_ship(dt, display): ship = Player(640/2,480/2, display, dt) add(ship) messenger.subscribe(ship.shoot, "shoot"); messenger.subscribe(ship.accelerate, "accelerate"); messenger.subscribe(ship.decelerate, "deaccelerate"); messenger.subscribe(ship.turnRight, "right"); messenger.subscribe(ship.turnLeft, "left"); messenger.subscribe(ship.draw, "render");
def add(entity): messenger.subscribe(entity.draw, "render") functions.append(lambda: entities.append(entity))
def initialize_ship(dt, display): ship = Player(640 / 2, 480 / 2, display, dt) add(ship) messenger.subscribe(ship.shoot, "shoot") messenger.subscribe(ship.accelerate, "accelerate") messenger.subscribe(ship.decelerate, "deaccelerate") messenger.subscribe(ship.turnRight, "right") messenger.subscribe(ship.turnLeft, "left") messenger.subscribe(ship.draw, "render")
play = PlayState('play', entitysystem); play.activate(); # unterschied zwischen transitionTo und activate? # setup StateMachine sm = StateMachine() # sm.start_state = splash # sm.end_state = end sm.setStartEnd(splash, end) sm.addState(play); sm.addTransition(splash, 'x', play) # bei event x #sm.addTransition(play, 'x', end) # bei event x # messenger.subscribe('x'); messenger.subscribe(lambda:sm.handle('x'), "x"); sm.activate() #teststates = {}; #teststates['src1'] = {}; #teststates['src2'] = {}; #teststates['src1']['msgX'] = 'destination1x' #teststates['src1']['msgY'] = 'destination1y' #teststates['src2']['msgZ'] = 'destination2z' # enable termination of application from each single state # messenger.subscribe(sm.handle(end), 'end') # game loop