def display( self, screen ): if self.grounded: xt, yt = Scrolling().location_pixels_to_meters( *self.aim ) vx, vy = physics.vxy( self.x0, xt, self.ax, self.y0, yt, self.ay, self.max_vx ) else: vx, vy = self.vxy # TODO: display curve of jump times = [ i/10. for i in range(21) ] x_points = [physics.position( self.x0, vx, self.ax, t ) for t in times] y_points = [physics.position( self.y0, vy, self.ay, t ) for t in times] points = zip( x_points, y_points ) points = [Scrolling().location_meters_to_pixels(*xy) for xy in points] pygame.draw.aalines( screen, c.RED, False, points )
def calculate_trajectory(self): mouse_x, mouse_y = pygame.mouse.get_pos() mouse_vector = Vector(mouse_x, mouse_y) angle = physics.angle(mouse_vector, self.mouse_position) power = physics.distance(self.mouse_position, mouse_vector) if power > self.max_power: power = self.max_power trajectory = physics.position(angle, power, self.position) return trajectory
def calculate_y( self, dt ): y = self.owner.bottom self.owner.bottom = physics.position( y, self.vy, self.ay, dt ) self.vy = physics.velocity( self.vy, self.ay, dt )
def calculate_x( self, dt ): self.owner.x = physics.position( self.owner.x, self.vx, self.ax, dt ) self.vx = physics.velocity( self.vx, self.ax, dt )