예제 #1
0
    def go_to(self, new_coords):
        new_new_coords = utilities.check_vector2(new_coords, float)

        if self.sprite.name == 'camera':
            self.position = [new_new_coords[0] - renderer.mid[0], new_new_coords[1] - renderer.mid[1]]
        else:
            self.position = new_new_coords
예제 #2
0
    def apply_force(self, force):
        new_force = utilities.check_vector2(force, float)

        if force[0] != 0 or force[1] != 0:

            x_component = new_force[0] / self.mass
            y_component = new_force[1] / self.mass

            self.velocity = utilities.add_vectors(self.velocity, (x_component, y_component))
예제 #3
0
    def move(self, position_change):
        new_position_change = utilities.check_vector2(position_change, float)

        # leave, stupid collisions
        previous_pos = self.position

        self.position = utilities.add_vectors(new_position_change, self.position)

        if self.check_collision():
            # self.position = previous_pos
            pass
예제 #4
0
    def check_point_collision(self, point):
        new_point = utilities.check_vector2(point, float)

        if new_point[0] < self.x:
            return False

        elif new_point[1] > self.x + self.size_x:
            return False

        elif new_point[0] < self.y:
            return False

        elif new_point[1] > self.y + self.size_y:
            return False

        return True
예제 #5
0
    def __step_in_range(self, step_range):
        new_step_range = utilities.check_vector2(step_range, int)

        if new_step_range[0] < 0:
            raise Exception(
                f'the first element of step animation range is too low ({new_step_range[0]}). '
                f'Please set it to a value greater than 0.')

        elif new_step_range[0] > new_step_range[1]:
            raise Exception(
                f'the first element of step animation range is higher than the second ({new_step_range[0]} > {new_step_range[1]}). '
                f'Please set it to a value smaller than the second.')

        elif step_range[1] > len(self.renders):
            raise Exception(
                f'step range out of bounds: ({new_step_range[1]} > {len(self.renders)}. '
                f'Please set it to a smaller value.')

        elif self.current_render < new_step_range[1]:
            self.current_render += 1

        else:
            self.current_render = new_step_range[0]
예제 #6
0
 def set_offset(self, offset):
     self.offset = utilities.check_vector2(offset, int)
예제 #7
0
    def set_size(self, size):
        new_size = utilities.check_vector2(size, int)

        self.size = (new_size[0], new_size[1])
def init(screen_size):
    scene_manager.new_scene('Untitled')

    renderer.init_screen(utilities.check_vector2(screen_size, int))

    unit_tests.Tests().run_all_tests()
예제 #9
0
 def set_velocity(self, velocity):
     self.velocity = utilities.check_vector2(velocity, float)
예제 #10
0
    def change_velocity(self, change):
        new_change = utilities.check_vector2(change, float)

        self.velocity = utilities.add_vectors(new_change, self.velocity)
예제 #11
0
 def set_position(self, position):
     new_pos = utilities.check_vector2(position, float)
     if new_pos is not False:
         self.x = new_pos[0]
         self.y = new_pos[1]
         self.__update_position()
예제 #12
0
    def set_position(self, position):
        new_position = utilities.check_vector2(position, int)

        self.x = new_position[0]
        self.y = new_position[1]
예제 #13
0
    def set_size(self, size):
        new_size = utilities.check_vector2(size, int)

        self.size_x = new_size[0]
        self.size_y = new_size[1]