def move_event( self, target_location ): if self.grounded: x0 = self.owner.x y0 = self.owner.bottom xt, yt = target_location vxy = physics.vxy( x0, xt, self.ax, y0, yt, self.ay, self.max_vx ) move_event = Event( Event.VELOCITY, values = vxy, targets = [self.owner] ) grounded_event = Event( Event.GROUNDED, values = (False,), targets = [self.owner] ) return move_event, grounded_event # TODO: in-air user controls else: pass return []
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 )