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
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))
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
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
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]
def set_offset(self, offset): self.offset = utilities.check_vector2(offset, int)
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()
def set_velocity(self, velocity): self.velocity = utilities.check_vector2(velocity, float)
def change_velocity(self, change): new_change = utilities.check_vector2(change, float) self.velocity = utilities.add_vectors(new_change, self.velocity)
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()
def set_position(self, position): new_position = utilities.check_vector2(position, int) self.x = new_position[0] self.y = new_position[1]
def set_size(self, size): new_size = utilities.check_vector2(size, int) self.size_x = new_size[0] self.size_y = new_size[1]