Compare commits
2 Commits
player-ani
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c41ef7535 | ||
|
|
c37d9d9911 |
25
player.py
25
player.py
@@ -174,13 +174,12 @@ class PlayerAnimation:
|
|||||||
# new root point created exactly on player
|
# new root point created exactly on player
|
||||||
self.add_point()
|
self.add_point()
|
||||||
|
|
||||||
# points are not removed so the camera can pan back up
|
# remove points in list that would make lines off the camera
|
||||||
# # remove points in list that would render lines off the camera
|
for point in self.points[1:]:
|
||||||
# for point in self.points[1:]:
|
if camera.entity_in_camera(point.x, point.y):
|
||||||
# if camera.entity_in_camera(point.x, point.y):
|
break
|
||||||
# break
|
|
||||||
|
|
||||||
# self.points.pop(0)
|
self.points.pop(0)
|
||||||
|
|
||||||
def update_draw(self, camera, isdecend=1):
|
def update_draw(self, camera, isdecend=1):
|
||||||
# debug render
|
# debug render
|
||||||
@@ -189,7 +188,7 @@ class PlayerAnimation:
|
|||||||
thumby.display.setPixel(int(pix_x), int(pix_y), isdecend)
|
thumby.display.setPixel(int(pix_x), int(pix_y), isdecend)
|
||||||
return
|
return
|
||||||
|
|
||||||
# draw line from last point to player
|
# root always reaches player position
|
||||||
if self.debug_exact:
|
if self.debug_exact:
|
||||||
x1, y1 = camera.relative_to_camera(self.player.x, self.player.y)
|
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)
|
x2, y2 = camera.relative_to_camera(self.points[-1].x, self.points[-1].y)
|
||||||
@@ -200,18 +199,10 @@ class PlayerAnimation:
|
|||||||
int(y2),
|
int(y2),
|
||||||
isdecend
|
isdecend
|
||||||
)
|
)
|
||||||
|
|
||||||
# draw line from last point to previous
|
# draw line from first position to next
|
||||||
point_off_camera_count = 2
|
|
||||||
point_prev = self.points[-1]
|
point_prev = self.points[-1]
|
||||||
for point in self.points[-2::-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)
|
x1, y1 = camera.relative_to_camera(point_prev.x, point_prev.y)
|
||||||
x2, y2 = camera.relative_to_camera(point.x, point.y)
|
x2, y2 = camera.relative_to_camera(point.x, point.y)
|
||||||
point_prev = point
|
point_prev = point
|
||||||
|
|||||||
Reference in New Issue
Block a user