2 Commits

Author SHA1 Message Date
Neal Finger
3c41ef7535 Merge pull request #14 from Markil3/player-animation-update
Update player.py
2023-02-12 13:30:00 -07:00
Neal Finger
c37d9d9911 Merge pull request #13 from Markil3/player-animation-update
Player animation update
2023-02-12 13:25:32 -07:00

View File

@@ -174,13 +174,12 @@ class PlayerAnimation:
# new root point created exactly on player
self.add_point()
# points are not removed so the camera can pan back up
# # remove points in list that would render lines off the camera
# for point in self.points[1:]:
# if camera.entity_in_camera(point.x, point.y):
# break
# remove points in list that would make lines off the camera
for point in self.points[1:]:
if camera.entity_in_camera(point.x, point.y):
break
# self.points.pop(0)
self.points.pop(0)
def update_draw(self, camera, isdecend=1):
# debug render
@@ -189,7 +188,7 @@ class PlayerAnimation:
thumby.display.setPixel(int(pix_x), int(pix_y), isdecend)
return
# draw line from last point to player
# root always reaches player position
if self.debug_exact:
x1, y1 = camera.relative_to_camera(self.player.x, self.player.y)
x2, y2 = camera.relative_to_camera(self.points[-1].x, self.points[-1].y)
@@ -200,18 +199,10 @@ class PlayerAnimation:
int(y2),
isdecend
)
# draw line from last point to previous
point_off_camera_count = 2
# draw line from first position to next
point_prev = self.points[-1]
for point in self.points[-2::-1]:
# break if entire line is off camera
if not camera.entity_in_camera(point.x, point.y):
point_off_camera_count -= 1
if point_off_camera_count <= 0:
break
x1, y1 = camera.relative_to_camera(point_prev.x, point_prev.y)
x2, y2 = camera.relative_to_camera(point.x, point.y)
point_prev = point