def __init__(self, *args): Mode.__init__(self, *args) self.game.lights['start'].blink(100, self.game.color(255,255,255)) self.packet_layer = TextLayer(TITLE_FONT, 'PACKET', self.game.color(255,255,255)) self.packet_layer.move(275, 150) self.storm_layer = TextLayer(TITLE_FONT, 'STORM', self.game.color(255,255,255)) self.storm_layer.move(475, 205) self.start_layer = TextLayer(BIG_FONT, 'PRESS START', self.game.color(255,255,255), align='center') self.start_layer.move(1024/2, 350) infile = open(__file__, 'r') code_lines = ['test'] # code_lines = [line.strip('\n') for line in infile.readlines()] infile.close() code_surf = renderLines(SMALL_FONT, code_lines, False, (45,45,45)) self.code_layer = DisplayLayer([code_surf]) self.layer = GroupedLayer([self.code_layer, self.packet_layer, self.storm_layer]) self.delay('blink', 0.5, self.blinkInsert, True) self.addHandler('start', 'closed', 0, self.startPressed) self.lightshow = Searchlight(self.game.lights.values(), 2.0)
def __init__(self, game, prio): Mode.__init__(self, game, prio) self.addHandler('flipL', 'closed', 0, self.flip) self.addHandler('flipR', 'closed', 0, self.flip) self.addHandler('flipL', 'open', 0, self.unflip) self.addHandler('flipR', 'open', 0, self.unflip)
def frame(self, delta): Mode.frame(self, delta) player = self.game.player() if player: self.score_layer.setText('%02d' % player.score) self.player_layer.setText(player.name) self.ball_layer.setText('Ball %s' % self.game.current_ball) else: self.player_layer.setText('Game over') self.ball_layer.setText('Game over')
def __init__(self, game, prio): Mode.__init__(self, game, prio) self.bumper_switches = ['pop1', 'pop2', 'pop3'] self.slingshot_switches = ['slingshotL', 'slingshotR'] for switch_name in self.slingshot_switches: self.addHandler(switch_name, 'closed', 0, self.slingshot) for switch_name in self.bumper_switches: self.addHandler(switch_name, 'closed', 0, self.bumper)
def __init__(self, game, prio): Mode.__init__(self, game, prio) self.score_layer = TextLayer(TITLE_FONT, '', self.game.color(255,255,255), align='center') self.score_layer.move(1024/2, 175) self.player_layer = TextLayer(SMALL_FONT, '', self.game.color(255,255,255)) self.player_layer.move(10, 360) self.ball_layer = TextLayer(SMALL_FONT, '', self.game.color(255,255,255), align='right') self.ball_layer.move(1014, 360) self.layer = GroupedLayer([self.score_layer, self.player_layer, self.ball_layer])
def __init__(self, game, prio, ball): ''' Constructor ''' Mode.__init__(self, game, prio) self.layer = TextLayer(ui.fonts.BIG_FONT, 'Ball %s locked' % ball, self.game.color(255,255,255), 'center') self.layer.move(1024/2, 175) self.layer.opaque = True self.delay('wait', 2, self.done)
def __init__(self, game, prio, switch_names, light_names): Mode.__init__(self, game, prio) self.switches = switch_names self.lights = light_names self.states = [False] * len(self.switches) for switch_name in self.switches: self.addHandler(switch_name, 'closed', 0, self.switchClosed) self.addHandler('flipL', 'closed', 0, self.rotateLeft) self.addHandler('flipR', 'closed', 0, self.rotateRight)
def frame(self, delta): Mode.frame(self, delta) if self.waiting: return bonus = self.ordered_bonuses[self.current_bonus_index] value = self.bonuses[bonus] bonus_str = '%s: %s' % (bonus, value) self.ms_since_bonus_displayed += delta*1000 last_letter = int(self.ms_since_bonus_displayed/self.ms_per_letter) if last_letter > len(bonus_str): last_letter = len(bonus_str) self.delay('next', 1.25, self.nextBonus) self.waiting = True partial_bonus_str = bonus_str[0:last_letter] self.bonus_layer.setText(partial_bonus_str)
def __init__(self, game, prio): Mode.__init__(self, game, prio) self.balls = 3 self.balls_in_play = 0 self.balls_in_lock = 0 self.balls_in_trough = self.balls self.trough_switches = ['trough1', 'trough2', 'trough3'] self.lock_switches = ['lock1', 'lock2', 'lock3'] self.outhole_switch = 'outhole' self.shooter_switch = 'shooter' self.addHandler(self.outhole_switch, 'closed', 30, self.ballDrained) for switch_name in self.trough_switches: self.addHandler(switch_name, 'closed', 0, self.handleTroughSwitch) for switch_name in self.lock_switches: self.addHandler(switch_name, 'closed', 0, self.handleLockSwitch) self.updateDebugInfo()
def __init__(self, game, prio, bonuses): Mode.__init__(self, game, prio) self.bonuses = bonuses # bonus name: score # bonus names sorted by bonus scores self.ordered_bonuses = [key for key, value in sorted(self.bonuses.items(), key=operator.itemgetter(1))] self.ordered_bonuses.append('Multiplier') self.bonuses['Multiplier'] = '%sx' % self.game.player().multiplier self.current_bonus_index = 0 self.current_letter_index = 0 self.ms_per_letter = 100 self.ms_since_bonus_displayed = 0 self.waiting = False self.message_layer = TextLayer(BIG_FONT, 'CONNECTION LOST', self.game.color(255,255,255), align='center') self.message_layer.move(1024/2, 130) self.bonus_layer = TextLayer(BIG_FONT, '', self.game.color(255,255,255), align='center') self.bonus_layer.move(1024/2, 195) self.layer = GroupedLayer([self.message_layer, self.bonus_layer])
def __init__(self, game, prio): Mode.__init__(self, game, prio) self.addHandler('scoop', 'closed', 30, self.ballInScoop) self.mode_menu_items = [MenuItem(self.game.datapath('menu_overload.png'), '1', self.game.color(255,255,255)), MenuItem(self.game.datapath('menu_takedown.png'), '2', self.game.color(255,255,255)), MenuItem(self.game.datapath('menu_codebreaker.png'), '3', self.game.color(255,255,255)), MenuItem(self.game.datapath('menu_item4.png'), '4', self.game.color(255,255,255)), MenuItem(None, 'mode 5', self.game.color(255,255,255)), MenuItem(None, 'mode 6', self.game.color(255,255,255))] self.mode_lights = ['ring1', 'ring2', 'ring3', 'ring4', 'ring5', 'ring6'] self.modes = [OverloadMode(game, 500, self), TakedownMode(game, 500, self), CodebreakerMode(game, 500, self), None, None, None] self.currently_selected_mode_index = 0 self.game.lights['scoop'].blink(100, self.game.color(255,255,255))
def __init__(self, game, prio, items, selection_callback=None, change_callback=None): Mode.__init__(self, game, prio) assert items self.use_alpha = False self.items = items self.selection_callback = selection_callback self.change_callback = change_callback self.current_item_index = 0 self.middle_item_position = (1024/2 - self.IMAGE_SIZE/2, self.BASE_HEIGHT+self.DIP_HEIGHT*1) self.left_item_position = (1024/2 - int(self.IMAGE_SIZE*1.5), self.BASE_HEIGHT+self.DIP_HEIGHT*0) self.right_item_position = (1024/2 + int(self.IMAGE_SIZE*0.5), self.BASE_HEIGHT+self.DIP_HEIGHT*0) self.new_left_item_position = (1024/2 - int(self.IMAGE_SIZE*2.5), self.BASE_HEIGHT-self.DIP_HEIGHT*1) self.new_right_item_position = (1024/2 + int(self.IMAGE_SIZE*1.5), self.BASE_HEIGHT-self.DIP_HEIGHT*1) self._rebuild() self.addHandler('flipR', 'closed', 0, self.rotateLeft) self.addHandler('flipL', 'closed', 0, self.rotateRight) self.addHandler('start', 'closed', 0, self.select)
def frame(self, delta): Mode.frame(self, delta) self.lightshow.frame(delta)