Exemplo n.º 1
0
    def __keyboard_movement_instruction(self, window, event):
        """ Sends movement instruction to facade

        Keyword arguments:
        window -- object the action occured on
        event -- contains information about the key press event

        """
        direction_conversion = {
            ord("a"): (-1, 0, 0),
            ord("d"): (1, 0, 0),
            ord("w"): (0, 1, 0),
            ord("s"): (0, -1, 0),
            ord("W"): (0, 1, 0),
            ord("S"): (0, -1, 0),
            ord("A"): (-1, 0, 0),
            ord("D"): (1, 0, 0),
            ord("e"): (0, 0, 1),
            ord("q"): (0, 0, -1),
        }

        speed_change = {45: -1, 43: 113}

        key_pressed = event.keyval

        if key_pressed in direction_conversion and self.__keyboard_input:
            self.__activate_arrow(key_pressed)
            direction = direction_conversion[key_pressed]
            direction = [x for x in direction]
            facade.move(direction, self.__x_axis_inverted, self.__y_axis_inverted)
        elif key_pressed in speed_change and self.__keyboard_input:
            facade.change_speed(None, speed_change[key_pressed])
Exemplo n.º 2
0
    def __keyboard_movement_instruction(self, window, event):
        """ Sends movement instruction to facade

        Keyword arguments:
        window -- object the action occured on
        event -- contains information about the key press event

        """
        direction_conversion = {97: (-1, 0, 0),
                                100: (1, 0, 0),
                                119: (0, 1, 0),
                                115: (0, -1, 0),
                                101: (0, 0, 1),
                                113: (0, 0, -1)}

        speed_change = {45 : -1, 43 : 1}

        key_pressed = event.keyval

        if key_pressed in direction_conversion and self.__keyboard_input:
            direction = direction_conversion[key_pressed]
            direction = [x for x in direction]
            facade.move(direction,
                        self.__x_axis_inverted,
                        self.__y_axis_inverted)
        elif key_pressed in speed_change and self.__keyboard_input:
            facade.change_speed(None, speed_change[key_pressed])
Exemplo n.º 3
0
    def __enter_movement_instruction(self, button):
        """ Sends movement instruction to facade

        Keyword arguments:
        button -- object the action occured on

        """
        direction_conversion = {0: (-1, 0, 0),
                                1: (1, 0, 0),
                                2: (0, 1, 0),
                                3: (0, -1, 0),
                                4: (0, 0, 1),
                                5: (0, 0, -1)}

        direction = direction_conversion[self.__builder.get_object(
                           "manual_control_instruction_combobox").get_active()]
        magnitude = self.__builder.get_object(
                           "manual_control_entry").get_text()

        if magnitude.isdigit():
            magnitude = int(magnitude)
            facade.move(list(magnitude * x for x in direction),
                                  self.__x_axis_inverted,
                                  self.__y_axis_inverted)
        else:
            log.log_error("The magnitude of a movement must be an integer, " \
                          "'{0}' is not an integer.".format(magnitude))
Exemplo n.º 4
0
    def __enter_movement_instruction(self, button):
        """ Sends movement instruction to facade

        Keyword arguments:
        button -- object the action occured on

        """
        direction_conversion = {0: (-1, 0, 0), 1: (1, 0, 0), 2: (0, 1, 0), 3: (0, -1, 0), 4: (0, 0, 1), 5: (0, 0, -1)}

        direction = direction_conversion[self.__builder.get_object("manual_control_instruction_combobox").get_active()]
        magnitude = self.__builder.get_object("manual_control_entry").get_text()

        if magnitude.isdigit():
            magnitude = int(magnitude)
            facade.move(list(magnitude * x for x in direction), self.__x_axis_inverted, self.__y_axis_inverted)
        else:
            log.log_error(
                "The magnitude of a movement must be an integer, " "'{0}' is not an integer.".format(magnitude)
            )