コード例 #1
0
    def start(self):
        self.start_time = hgt.time.now
        self.above_surface = False
        self.grabbed_fish_info = None
        self.falling_fish = []
        self.touchable_enemies = True
        self.shock_the_player = False
        self.current_force = Vec3f(0, 0, 0)
        self.game_ending = False
        self.drop_in_left_bucket = True
        self.last_fish_drop_time = None

        space.nodes["ToggleGroup_FishBox"].graphicsOn = False
        space.nodes["ToggleGroup_Dropbox"].graphicsOn = False
        space.nodes["ToggleGroup_Dropbox2"].graphicsOn = False
        space.nodes["ToggleGroup_InnerAquariumGlass"].graphicsOn = False

        if self.level < 3:
            space.nodes["ToggleGroup_GuideArrow"].graphicsOn = False
            space.nodes["Appearance_RightBucket"].material = self.left_bucket_material.h3dNode

        space.nodes["Text_Level"].string = [_('Level') + ': ' + [_('Easy'), _('Medium'), _('Hard')][self.level - 1]]

        self.score = 0
        space.nodes["Text_Score"].string = [_("Score") + ":", "%d" % self.score]

        if self.level == 3:
            hgt.time.add_timeout(2.0, self.music_sound.play)
コード例 #2
0
    def reset(self):
        # Clear labels
        space.nodes["Text_Hint"].string = [_("Touch correct answer!")]
        space.nodes["Text_Solution"].string = []
        space.nodes["Text_ProblemLine1"].string = []
        space.nodes["Text_ProblemLine2"].string = []
        space.nodes["Text_ProblemNumberLabel"].string = [_("Problem") + ':']
        space.nodes["Text_ProblemNumber"].string = [
            "1 / %d" % self.number_of_problems
        ]
        space.nodes["Text_Score"].string = ["0"]
        space.nodes["Text_ScoreLabel"].string = [_("Score") + ':']
        space.nodes["Text_EndLabel"].string = [""]
        for i in range(self.number_of_answers):
            space.nodes["Text_Answer%d" % i].string = []

        # Reset stats
        self.score = 0
        self.problem_number = 0
        self.mistakes = 0
        self.current_mistakes = 0
        self.perfect_answers = 0
        self.streak = 0
        self.answering_enabled = False
        hgt.time.add_timeout(MEDIUM_TIMEOUT, self.create_problem)

        if self.level == 3:
            self.music_sound.play()
        self.game_ending = False
コード例 #3
0
 def start(self):
     self.start_time = hgt.time.now
     self.sequence_index = 0
     space.nodes["Text_Message"].string = [
         _('Touch the green bubble.'),
         _('Follow the arrows.')
     ]
コード例 #4
0
    def finished(self):
        self.game_ending = True

        if self.perfect_answers == 10:
            space.nodes["Text_EndLabel"].string = [_("Flawless!")]
        elif self.perfect_answers == 9:
            space.nodes["Text_EndLabel"].string = [_("Excellent!")]
        elif self.perfect_answers > 6:
            space.nodes["Text_EndLabel"].string = [_("Good job!")]
        elif self.perfect_answers > 4:
            space.nodes["Text_EndLabel"].string = [_("Well done!")]
        else:
            space.nodes["Text_EndLabel"].string = [_("Keep working!")]

        hgt.time.add_timeout(END_TIMEOUT, self.finished2)
コード例 #5
0
    def touch_target(self, evt):
        ti = evt.target_info

        self.log_event("target_press", "Pressed target %d" % ti['target_id'], id = ti['target_id'])

        if not ti['done'] and not ti['touched_this_round']:
            ti['touched_this_round'] = True


            # Correct target
            if ti['target_id'] == self.sequence_index:
                ti['appearance'].material = self.correct_target_material.h3dNode
                ti['done'] = True
                self.reset_targets()
                self.correct_sound.play()

                self.log_event("target_press_correct", "Pressed correct target %d" % ti['target_id'], id = ti['target_id'])

                if DRAW_LINES and self.sequence_index > 0:
                    self.draw_line(
                        self.target_infos[self.sequence_index - 1]['original_position'],
                        self.target_infos[self.sequence_index]['original_position']
                    )

                self.sequence_index += 1
                if self.sequence_index == NUMBER_OF_TARGETS:
                    space.nodes["Text_Message"].string = [_("Thanks.")]
                    hgt.time.add_timeout(END_TIMEOUT, self.end_assessment)

            # Wrong target
            else:
                ti['appearance'].material = self.wrong_target_material.h3dNode
                self.wrong_sound.play()
                self.errors += 1
                self.log_event("target_press_incorrect", "Pressed incorrect target %d" % ti['target_id'], id = ti['target_id'])
コード例 #6
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
    def build(self):
        random.seed()

        # Setup hgt world
        hgt.world.stereoInfo.focalDistance = 0.55
        hgt.world.tilt(-SPACE_TILT)
        hgt.world.load_stylus('ball')

        cfg = self.load_config()
        self.level = cfg.settings["colors_level"]

        # Level determines number of squares in grid:
        self.gridW = [5, 10, 15][self.level - 1]

        self.colors = []

        # Load Blender scene
        self.add_child(space.world)

        self.build_color_pulser()

        # a growing blob of colored squares
        self.blob = set()

        self.build_sounds()
        self.build_buttons()
        self.build_grid()
        self.set_adjacents()

        # score text
        #t2 = hgn.Transform(translation = Vec3f(0, 0.05, ZFOO))
        t2 = space.nodes["Transform_LabelPosition"]

        t = hgn.Transform(translation=Vec3f(0, 0, 0))
        self.scoreText = TextShape(string=["00"],
                                   size=0.03,
                                   family="Droid Sans",
                                   justify="MIDDLE")
        self.scoreText.material.emissiveColor = RGB(1, 1, 1)
        t.add(self.scoreText.node)

        t2.add(t)

        t = hgn.Transform(translation=Vec3f(0, 0.025, 0))
        st = TextShape(string=[_("Moves")],
                       size=0.01,
                       family="Droid Sans",
                       justify="MIDDLE")
        st.material.emissiveColor = RGB(1, 1, 1)
        t.add(st.node)
        t2.add(t)

        self.update_blob()

        self.turns = 0
        self.set_text()

        self.tone_history = []

        self.game_ended = False
コード例 #7
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
    def endgame3(self):
        self.ping_sound.play()

        l = len(self.sequence)
        if l <= 2:
            s = _("Please try again!")
            sc = 0.0
        elif l <= 3:
            s = _("You won the small trophy!")
            sc = 0.3
        elif l <= 5:
            s = _("You won the medium trophy!")
            sc = 0.5
        elif l <= 7:
            s = _("You won the large trophy!")
            sc = 0.7
        elif l <= 9:
            s = _("You won the huge trophy!")
            sc = 0.9
        elif l <= 11:
            s = _("You won the gigantic trophy!")
            sc = 0.9
        else:
            s = _("You won the gargantuan trophy!")
            sc = 1.0

        self.medium_text.string = [s]
        self.cup_transform.scale = sc * Vec3f(1, 1, 1)

        hgt.time.add_timeout(2.0, self.endgame4)
コード例 #8
0
    def reset(self):
        self.state.change(self.states.not_lifting)
        self.last_plate_touched = None
        #self.score = 0

        space.nodes["Text_LevelLabel"].string = [_('LEVEL')]
        #space.nodes["Text_ScoreLabel"].string = [_('SCORE')]
        space.nodes["Text_Level"].string = [[
            _('Easy'), _('Medium'), _('Hard')
        ][self.level - 1]]

        #print "level", self.level
        #print "number_of_colors:", self.number_of_colors

        self.combination = []
        for i in range(self.mugs_per_shelf):
            self.combination.append(
                random.randint(0, self.number_of_colors - 1))
コード例 #9
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
    def reset(self):
        space.nodes["Text_LevelLabel"].string = [_('LEVEL')]
        space.nodes["Text_ScoreLabel"].string = [_('SCORE')]
        space.nodes["Text_Level"].string = [[
            _('Easy'), _('Medium'), _('Hard')
        ][self.level - 1]]

        self.sequence_index = 0
        self.score = 0
        self.current_number = 0
        self.sequence_index = -1

        if self.level == 3:
            self.music_sound.play()

        random.shuffle(self.sequence)

        self.new_round()
コード例 #10
0
    def reset(self):
        self.any_target_or_distractor_pressed = False
        self.first_target_press_time = None
        self.target_represses = 0
        self.unique_target_presses = 0
        self.target_x_values = []
        self.target_y_values = []
        self.center_of_cancellation = 0.0

        # Scores for Dashboard (unique left target presses / unique right target presses)
        self.left_score = 0
        self.right_score = 0
        self.middle_score = 0

        # Display user instructions
        space.nodes["Text_Message"].string = [
            _("Press all green circles marked '1'."),
            _("Press a red '0' when you are finished."),
        ]

        # Enable target presses
        self.assessment_running = True
コード例 #11
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
    def reset(self):
        self.music_sound.play()
        self.reset_bow_strings()
        self.aiming = False
        self.firing = False
        self.score = 0
        self.increment_score(0)
        self.arrow_travel_distance = 0.0
        self.arrows_left = 20
        self.update_arrow_counter()
        self.game_is_ending = False
        self.hit_arrow_info = None

        self.target_list = [
            space.nodes["Transform_Target.000"],
            space.nodes["Transform_Target.001"],
            space.nodes["Transform_Target.002"],
        ]

        space.nodes["Text_ScoreLabel"].string = [_("Score")]
        space.nodes["Text_ArrowLabel"].string = [_("Arrows")]
        space.nodes["ToggleGroup_FinalScore"].graphicsOn = False
コード例 #12
0
    def press_answer_pad(self, evt):
        ap = evt.info

        #self.play_chalk_sound()

        if self.answering_enabled and not ap['answered']:
            if ap['answer'] == self.problem_solution:
                self.answering_enabled = False
                ap['material'].diffuseColor = RGB(0, 1, 0)
                self.streak += 1
                if self.streak > 2:
                    space.nodes["Text_Hint"].string = [
                        "%d %s" % (self.streak, _("in a row!"))
                    ]

                # Set feedback position
                space.nodes["Transform_FeedbackLabel"].translation = ap[
                    'feedback_pos']

                self.write_answer()
            else:
                ap['material'].diffuseColor = RGB(1, 0, 0)
                self.mistakes += 1
                self.current_mistakes += 1
                self.streak = 0
                ap['answered'] = True
                space.nodes["Text_Hint"].string = [_("Touch correct answer!")]

                # Negative score feedback
                random.choice(self.chalktap_sounds).play()
                penalty = self.mistake_penalty
                space.nodes["Transform_FeedbackLabel"].translation = ap[
                    'feedback_pos']
                space.nodes["Text_FeedbackLabel"].string = ["-%d" % penalty]
                self.feedback_fader.startTime = hgt.time.now
                self.score -= penalty
                if self.score < 0:
                    self.score = 0
                space.nodes["Text_Score"].string = [str(self.score)]
コード例 #13
0
    def build_hud(self):
        self.speedText = hud = TextShape(string=["0"])
        hud.material.emissiveColor = RGB(1, 1, 1)
        t = hgn.Transform(translation=Vec3f(0.25, 0.52, 0))
        t.add(hud.node)
        self.cam.add(t)

        hud = TextShape(size=0.02, string=[_("KM/H")])
        hud.material.emissiveColor = RGB(1, 1, 1)
        t = hgn.Transform(translation=Vec3f(0.25, 0.49, 0))
        t.add(hud.node)
        self.cam.add(t)

        self.timeText = hud = TextShape(string=["0:00:00"])
        hud.material.emissiveColor = RGB(1, 1, 1)
        t = hgn.Transform(translation=Vec3f(0, 0.52, 0))
        t.add(hud.node)
        self.cam.add(t)

        hud = TextShape(size=0.02, string=[_("Time")])
        hud.material.emissiveColor = RGB(1, 1, 1)
        t = hgn.Transform(translation=Vec3f(0, 0.49, 0))
        t.add(hud.node)
        self.cam.add(t)

        self.lapText = hud = TextShape(string=["1/%s" % NUMBER_OF_LAPS])
        hud.material.emissiveColor = RGB(1, 1, 1)
        t = hgn.Transform(translation=Vec3f(-0.25, 0.52, 0))
        t.add(hud.node)
        self.cam.add(t)

        hud = TextShape(size=0.02,
                        string=[_("Lap", "Laps", count=NUMBER_OF_LAPS)])
        hud.material.emissiveColor = RGB(1, 1, 1)
        t = hgn.Transform(translation=Vec3f(-0.25, 0.49, 0))
        t.add(hud.node)
        self.cam.add(t)
コード例 #14
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
    def new_round(self):
        self.sequence_index += 1
        self.update_labels()

        space.nodes["ToggleGroup_CurrentNumberLabel"].graphicsOn = False
        space.nodes["Text_CurrentNumber"].string = []
        space.nodes["Text_CurrentNumberLabel"].string = [_('FIND:')]

        # End game
        if self.sequence_index == self.number_of_buttons:  # note: sequence_index updated above
            self.state.change(self.states.ending)
            hgt.time.add_timeout(1.0, self.end_game)

        # Continue game
        else:
            self.state.change(self.states.waiting)
            hgt.time.add_timeout(1.0, self.clean_board)
コード例 #15
0
    def touch_target(self, evt):
        ti = evt.target_info
        # Correct target
        if ti['target_id'] == self.sequence_index:
            ti['toggle'].graphicsOn = False
            ti['toggle'].hapticsOn = False

            self.pop_sound.play()

            self.log_event("press_target", "Press target %02d" % ti['target_id'], target=ti['target_id'])

            self.sequence_index += 1
            if self.sequence_index == NUMBER_OF_TARGETS:
                space.nodes["Text_Message"].string = [_('Thanks!')]
                hgt.time.add_timeout(END_TIMEOUT, self.end_assessment)
            else:
                self.target_infos[self.sequence_index]['appearance'].material = self.next_target_material.h3dNode
                #self.target_infos[self.sequence_index]['toggle'].graphicsOn = True
                self.target_infos[self.sequence_index]['toggle'].hapticsOn = True
コード例 #16
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
    def build_world(self):
        self.scoreText = space.nodes["Text_SCORE"]
        self.movesText = space.nodes["Text_MOVES"]
        self.movesText.string = [_("MOVES")]
        space.nodes["Text_LevelLabel"].string = [_('LEVEL')]
        space.nodes["Text_Level"].string = [[
            _('Easy'), _('Medium'), _('Hard')
        ][self.level - 1]]

        self.cardTurnSound = Sound(url="sounds/flip.wav",
                                   copies=2,
                                   intensity=0.5)
        self.noTurnSound = Sound(url="sounds/click.wav",
                                 copies=2,
                                 intensity=1.0)
        self.wrongPairSound = Sound(url="sounds/click.wav",
                                    copies=1,
                                    intensity=1.0)
        self.correctPairSound = Sound(url="sounds/ding.wav",
                                      copies=1,
                                      intensity=1.0)
        self.finishedSound = Sound(url="sounds/cheer.wav",
                                   copies=1,
                                   intensity=0.5)

        self.cards = []

        for i in range(MAX_CARDS):
            cardMesh = space.nodes["Mesh_C%d" % (i)]
            cardT = space.nodes["Transform_C%d" % (i)]
            cardAppearance = space.nodes["Appearance_C%d" % (i)]
            toggle = space.nodes["ToggleGroup_C%d" % (i)]

            if i not in self.cardsUsed:
                # Hide unused cards
                toggle.graphicsOn = False
                toggle.hapticsOn = False
            else:
                imageTexture = hgn.ImageTexture(url="textures/cardback.jpg")

                card = Card(backTexture=imageTexture,
                            appearance=cardAppearance,
                            toggle=toggle)
                self.cards.append(card)

                event = Event()
                event.card = card

                button = PushButton(
                    transformNode=cardT.h3dNode,
                    geometry=cardMesh.h3dNode,
                    onPress=self.press_card,
                    displacement=Vec3f(0, 0, -0.005),
                    event=event,
                )

        cardfronts = []
        for fn in os.listdir('cardimages'):
            if fn.endswith('.jpg'):
                cardfronts.append('cardimages/' + fn)

        random.shuffle(cardfronts)
        random.shuffle(self.cards)

        for i in range(len(self.cardsUsed) / 2):
            index = i * 2
            cardfront = hgn.ImageTexture(url=cardfronts.pop())
            c1 = self.cards[index]
            c2 = self.cards[index + 1]

            c1.frontTexture = cardfront
            c2.frontTexture = cardfront

            c1.pairId = i
            c2.pairId = i
コード例 #17
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
 def endgame2(self):
     self.ping_sound.play()
     self.large_text.string = [
         "%s: %d" % (_("Final Score"), len(self.sequence) - 1)
     ]
     hgt.time.add_timeout(2.0, self.endgame3)
コード例 #18
0
    def build_world(self):
        # Labels
        space.nodes["Text_Message"].string = [_("Touch all targets in order (1-2-3 ...)")]

        # Sounds
        self.correct_sound = Sound("sounds/correct.wav", copies=3, intensity=0.5)
        self.wrong_sound = Sound("sounds/wrong.wav", copies=3, intensity=0.5)

        # Gather target materials
        self.default_target_material = space.nodes["Material_DefaultTarget"]
        self.correct_target_material = space.nodes["Material_CorrectTarget"]
        self.wrong_target_material = space.nodes["Material_WrongTarget"]

        self.target_infos = []

        for i in range(NUMBER_OF_TARGETS):
            target = X3DFileNode("target.hgt")
            self.add_child(target)

            # Make the haptic part invisible
            target.find("ToggleGroup_TargetHaptic").graphicsOn = False

            # Set the label
            if ALPHANUMERIC_SEQUENCE:
                if i % 2 == 0:
                    label = str((i / 2) + 1)
                else:
                    label = chr(ord('A') + (i / 2))
            else:
                label = str(i + 1)
            target.find("Text_TargetLabel").string = [label]

            # Set outline appearance to default color (black)
            appearance = target.find("Appearance_TargetOutline")
            appearance.material = self.default_target_material.h3dNode

            # Position the target according to the corresponding
            # empty in the scene.
            transform = target.find("Transform_TargetEmpty")
            empty_transform = space.nodes["Transform_CircleEmpty.%03d" % i]
            transform.translation = empty_transform.translation

            # Create target info
            target_info = {
                'appearance': appearance,
                'done': False,
                'original_position': transform.translation,
                'target_id': i,
                'touched_this_round': False,
            }

            self.target_infos.append(target_info)

            # Bind touch
            evt = Event()
            evt.target_info = target_info

            bl = MFBoolListener(
                onTrue=self.touch_target,
                callbackObject=evt
            )

            target.find("Mesh_TargetHaptic").h3dNode.isTouched.routeNoEvent(bl)
コード例 #19
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
 def show_reminder(self):
     self.fairy_sound.play()
     self.medium_text.string = [_("There are more tones to play...")]
     # FIXME: multiple callbacks might still be created
     self.reminder_timeout = None
コード例 #20
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
    def build_world(self):
        # Labels
        # FIXME: blender exporter bug requires fixing before the label names can
        # be changed to something more appropriate.
        space.nodes["Text_LengthLabel.001"].string = [_("Listen")]
        space.nodes["Text_LengthLabel.002"].string = [_("Repeat")]

        # Hide all buttons
        for i in range(TOTAL_NUMBER_OF_BUTTONS):
            t = space.nodes["ToggleGroup_Button.%03d" % (i + 1)]
            t.hapticsOn = False
            t.graphicsOn = False

        self.buttons = []
        for id in self.level_button_ids:
            # Make button visible again
            t = space.nodes["ToggleGroup_Button.%03d" % (id)]
            t.hapticsOn = True
            t.graphicsOn = True

            button = {
                "mesh":
                space.nodes["Mesh_Button.%03d" % (id)],
                "transformInfo":
                space.nodes["TransformInfo_Button.%03d" % (id)],
                "transform":
                space.nodes["Transform_Button.%03d" % (id)],
                "material":
                space.nodes["Material_Button.%03d" % (id)],
                "sound":
                Sound(url="sounds/instrument/%s.wav" %
                      self.level_sounds.pop(0),
                      copies=3,
                      intensity=0.5),
            }
            self.buttons.append(button)

            e = Event()
            e.button = button

            pushButton = PushButton(
                transformNode=button["transform"].h3dNode,
                geometry=button["mesh"].h3dNode,
                onPress=self.press_button,
                onRelease=self.release_button,
                displacement=Vec3f(0, 0.01, 0),
                hitForce=1.5,
                event=e,
            )

        # The reward
        self.cup_toggle = space.nodes["ToggleGroup_Cup"]
        self.cup_transform = space.nodes["Transform_Cup"]
        self.cup_dynamic_transform = space.nodes["DynamicTransform_Cup"]
        #self.cup_dynamic_transform.angularMomentum = Vec3f(0, 0, 0.5)
        self.cup_toggle.graphicsOn = False
        self.cup_toggle.hapticsOn = False

        # Build sounds
        self.click_sound = Sound(url="sounds/click.wav",
                                 copies=2,
                                 intensity=0.2)
        self.switch_sound = Sound(url="sounds/switch.wav",
                                  copies=2,
                                  intensity=0.2)
        self.error_sound = Sound(url="sounds/error.wav",
                                 copies=2,
                                 intensity=0.2)
        self.fanfare_sound = Sound(url="sounds/fanfare.wav",
                                   copies=2,
                                   intensity=0.2)
        self.ping_sound = Sound(url="sounds/ping.wav", copies=2, intensity=0.2)
        self.fairy_sound = Sound(url="sounds/fairy.wav",
                                 copies=2,
                                 intensity=0.2)

        # Lights
        self.button_glow_lamp = space.nodes["PointLight_ButtonGlow"]

        # Texts
        self.sequence_length_text = space.nodes["Text_LengthLabel"]
        self.sequence_length_text.string = []
        self.large_text = space.nodes["Text_LargeLabel"]
        self.large_text.string = []
        self.medium_text = space.nodes["Text_MediumLabel"]
        self.medium_text.string = []

        # Leds
        self.led_materials = []
        for i in range(2):
            m = space.nodes["Material_LED%d" % (i + 1)]
            self.led_materials.append(m)
        self.leds_off()
コード例 #21
0
 def increment_score(self, inc):
     self.score += inc
     if self.score < 0:
         self.score = 0
     space.nodes["Text_Score"].string = [_("Score") + ":", "%d" % self.score]
コード例 #22
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
 def end_game(self):
     self.ping_sound.play()
     space.nodes["Text_FinalScore"].string = [_("Score") + ':', str(self.score)]
     space.nodes["ToggleGroup_FinalScore"].graphicsOn = True
     self.final_score_grower.startTime = hgt.time.now
     hgt.time.add_timeout(5.0, self.end_game2)
コード例 #23
0
    def press_done(self, evt):
        self.log_event("exit_press", "Pressed exit button")

        space.nodes["Text_Message"].string = [_("Thanks!")]
        self.assessment_running = False
        hgt.time.add_timeout(2, self.end_assessment)
コード例 #24
0
    def build_world(self):
        # Slot machine buttons
        self.button_infos = {
            'spin_reels': {
                'name': 'SpinButton',
                'title': _('SPIN'),
                'id': 'spin_reels',
                'label': space.nodes["Text_SpinButtonLabel"],
                'material': space.nodes["Material_SpinButton"],
            },
            'bet_one': {
                'name': 'BetButton',
                'title': _('BET'),
                'id': 'bet_one',
                'label': space.nodes["Text_BetButtonLabel"],
                'material': space.nodes["Material_BetButton"],
            },
            'exit': {
                'name': 'ExitButton',
                'title': _('EXIT'),
                'id': 'exit',
                'label': space.nodes["Text_ExitButtonLabel"],
                'material': space.nodes["Material_ExitButton"],
            },
        }

        for i in range(3):
            bid = "hold%d" % i
            self.button_infos[bid] = {
                'name': 'HoldButton.%03d' % i,
                'title': _('HOLD'),
                'id': 'hold0',
                'label': space.nodes["Text_HoldButtonLabel.%03d" % i],
                'material': space.nodes["Material_HoldButton.%03d" % i],
            }

        for bi in self.button_infos.values():
            # Set label
            bi['label'].string = [bi['title']]

            e = Event()
            e.info = bi
            pushButton = PushButton(
                transformNode=space.nodes["Transform_%s" % bi['name']].h3dNode,
                geometry=space.nodes["Mesh_%s" % bi['name']].h3dNode,
                displacement=Vec3f(0, 0.005,
                                   0),  # push down 5 mm in negative z dir
                onPress=self.press_button,
                pressSound=self.button_up_sound,
                releaseSound=self.button_down_sound,
                event=e,
            )

            self.disable_button(bi)

        # Coin
        transform = space.nodes["Transform_TopCoin"]
        grabObject = self.grabber.register(
            transform=transform,
            toggle=space.nodes["ToggleGroup_TopCoin"],
        )
        evt = Event()
        evt.info = {
            'transform': transform,
            'grabObject': grabObject,
            'originalTranslation': transform.translation,
            'originalRotation': transform.rotation,
        }
        bl = MFBoolListener(
            onTrue=self.touch_coin,
            callbackObject=evt,
        )
        space.nodes["Mesh_TopCoin"].h3dNode.isTouched.routeNoEvent(bl)

        # Coin slot
        bl = MFBoolListener(onTrue=self.touch_coin_slot, )
        space.nodes["Mesh_CoinSlot"].h3dNode.isTouched.routeNoEvent(bl)
コード例 #25
0
ファイル: hgtgame.py プロジェクト: BlenderCN-Org/curictus
 def start(self):
     space.nodes["Text_UserMessage"].string = [_("Touch everything.")]
     space.nodes["Text_UserMessage2"].string = [_("Press exit sign when done.")]
     self.startTime = hgt.time.now