Exemplo n.º 1
0
    def tick( indev, guistate ):
        if SingleSwitch.is_enabled:
            if indev.any_went_down():
                SingleSwitch.next_cnt = 0

            SingleSwitch.next_cnt += 1
            if SingleSwitch.next_cnt >= SingleSwitch.scan_timeout:
                SingleSwitch.next_cnt = 0
                if guistate is not None:
                    guistate.activate_next()

            # Remove non down buttons
            new_timers = {}
            for key, value in SingleSwitch.esc_timers.items():
                if key.button in key.dev.down_buttons:
                    new_timers[ key ] = value
            SingleSwitch.esc_timers = new_timers

            # Add buttons
            SingleSwitch.esc_went_down = False
            for dev in indev.devs_no_mouse:
                for key in dev.down_buttons:
                    btn = input.Button( dev, key )
                    if SingleSwitch.esc_timers.has_key( btn ):
                        SingleSwitch.esc_timers[ btn ] += 1
                    else:
                        SingleSwitch.esc_timers[ btn ] = 1

                    if SingleSwitch.esc_timers[ btn ] == 25:
                        SingleSwitch.esc_went_down = True
Exemplo n.º 2
0
    def __init__( self, game_data, player_cnt ):
        Component.__init__( self )

        self.game_data = game_data
        self.game_data.goldcars = []
        self.player_cnt = player_cnt
        self.current_player = 1

        btnFont = Font( "data/edmunds.ttf", color=(0,0,0), size=32, use_antialias = True )

        self.textLabel = Label( Vec2D(250, 300), _("Player 1, press button!"), btnFont )

        self.car_sprite = resman.get("game.car1_sprite")
        self.carLabel =  Label( Vec2D(400, 240), image=self.car_sprite )
        self.anim_timer = LoopAnimationTimer( 15, 40, 12 )


        self.add_subcomponent( self.textLabel )
        self.add_subcomponent( self.carLabel )

        self.forbidden_buttons = [input.Button(self.game_data.userinput.key, K_ESCAPE)]

        for joy in self.game_data.userinput.joys:
            self.forbidden_buttons.append(input.Button(joy, Joystick.BTN_BACK))
Exemplo n.º 3
0
    def tick( self, userinput, guistate ):
        Component.tick( self, userinput, guistate )

        for dev in userinput.devs_no_mouse:
            if dev.any_went_down():
                Event.playerkey()
                button = input.Button(dev, dev.went_down_buttons[0])

                if button not in self.forbidden_buttons:
                    resman.get("gui.key_good_sound").play()
                    self.forbidden_buttons.append( button )

                    if self.current_player <= self.player_cnt:
                        player_data = [_("Player %d") % self.current_player, ctrl.HumanController( None, button )]
                        self.game_data.goldcars.append( player_data )

                    self.current_player += 1
                    if self.current_player <= self.player_cnt:
                        self.update_labels()
                else:
                    resman.get("gui.key_bad_sound").play()
Exemplo n.º 4
0
    def check_enable( indev ):
        if not SingleSwitch.is_enabled:
            # Remove non down buttons
            new_timers = {}
            for key, value in SingleSwitch.esc_timers.items():
                if key.button in key.dev.down_buttons:
                    new_timers[ key ] = value
            SingleSwitch.esc_timers = new_timers

            # Add buttons
            SingleSwitch.esc_went_down = False
            for dev in indev.devs_no_mouse:
                for key in dev.down_buttons:
                    btn = input.Button( dev, key )
                    if SingleSwitch.esc_timers.has_key( btn ):
                        SingleSwitch.esc_timers[ btn ] += 1
                    else:
                        SingleSwitch.esc_timers[ btn ] = 1

                    if SingleSwitch.esc_timers[ btn ] == 25 * 3:
                        SingleSwitch.is_enabled = True
Exemplo n.º 5
0
    def set_type(self, gametype):
        self.gametype = gametype

        if self.gametype == GameType.SINGLE_SEQUENCE:
            self.goldcars = [[
                "Player",
                ctrl.HumanController(None,
                                     input.Button(self.userinput.key, K_SPACE))
            ]]

        elif self.gametype == GameType.SINGLE_RANDOM:
            self.goldcars = [[
                "Player",
                ctrl.HumanController(None,
                                     input.Button(self.userinput.key, K_SPACE))
            ]]

        elif self.gametype == GameType.MULTI_RANDOM:
            #            self.goldcars = [["AI", ctrl.AiController( None )]]
            self.goldcars = [["AI", ctrl.AiController(None)],
                             ["AJ", ctrl.AiController(None)]]


#            self.goldcars = [["Koen", ctrl.HumanController( None, input.Button(self.userinput.key, K_SPACE) )],
#                             ["Leen", ctrl.AiController( None )],
#                             ["Computer", ctrl.AiController( None )]]
#            self.goldcars = [["Koen", ctrl.HumanController( None, input.Button(self.userinput.key, K_SPACE) )]]

        else:
            self.goldcars = [
                [
                    "Koen",
                    ctrl.HumanController(
                        None, input.Button(self.userinput.key, K_SPACE))
                ],
                [
                    "Koen",
                    ctrl.HumanController(
                        None, input.Button(self.userinput.key, K_SPACE))
                ],
                [
                    "Koen",
                    ctrl.HumanController(
                        None, input.Button(self.userinput.key, K_SPACE))
                ],
                [
                    "Koen",
                    ctrl.HumanController(
                        None, input.Button(self.userinput.key, K_SPACE))
                ],
                ##                             ["Koen", ctrl.HumanController( None, input.Button(self.userinput.key, K_SPACE) )]]
                ##                             ["Leen", ctrl.AiController( None )]]
                ["Computer", ctrl.AiController(None)]
            ]
        #                     ["Leen", HumanController( None, input.Button(self.userinput.key, K_z) )]]

        self.scenario_nr = 0
        self.level_nr = 0  #self.scenario_nr

        quest_manager = QuestManager.get_instance()
        if self.gametype == GameType.TEST:
            self.quest = Quest()
            self.quest.add_level(ScenarioCollectAll(120, 150, []), 27)
            self.quest.add_level(ScenarioBlowup(120, None, [Balloon], True), 8,
                                 [])
            self.quest.add_level(ScenarioHoldLamp(TIMEOUT, None, [], True), 72,
                                 [1.0, 1.0])
            self.quest.add_level(ScenarioHoldLamp(None, 60, [], False), 8,
                                 [1.0, 1.0, 1.0])

            self.quest.add_level(ScenarioCoinCollect(120, None, 3, []), 39)
            self.quest.add_level(ScenarioBlowup(120, None, [Key]), 86)
            self.quest.add_level(ScenarioCoinCollect(120, None, 1, []), 4)
            self.quest.add_level(ScenarioCutter(120, None, [Balloon]), 1)
            self.quest.add_level(ScenarioHoldLamp(120, None, [Balloon]), 6)
            self.quest.add_level(ScenarioCoinCollect(120, None, 20, []), 4)
            self.quest.add_level(ScenarioCutter(120, None, []), 1)
            self.quest.add_level(ScenarioDiamondCollect(120, None, 1, []), 6)
            self.quest.add_level(ScenarioHoldLamp(120, None, []), 6)
            #            quest.add_level( ScenarioCollectRocks( 120, 60, [] ), 4 )
            #            quest.add_level( ScenarioCollectAll( 120, 150, [] ), 5 )
            self.quest.add_level(ScenarioPacman(None, 0), 1)
            self.quest.add_level(
                ScenarioCoinCollect(120, None, 1, [Multiplier]), 1)

        elif self.gametype == GameType.SINGLE_SEQUENCE:
            self.quest = quest_manager.get_quest(QuestManager.MAIN_QUEST)

            self.quest.progress = self.single_player_progress

        elif self.gametype == GameType.SINGLE_RANDOM:
            self.quest = quest_manager.get_quest(
                QuestManager.SINGLE_RANDOM_QUEST)
            self._fill_random_quest_items()
            self.total_scores = {}
        else:
            self.quest = quest_manager.get_quest(
                QuestManager.MULTI_RANDOM_QUEST)
            self._fill_random_quest_items()
            self.total_scores = {}