Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

commit bd76dcc88bfa060f836bc5ab48909b56509d208d
parent 0f7d7113d56d39304548fd023abc5b3f4ded8948
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Fri, 30 Oct 2020 17:53:51 -0500

Camera now has limits on how far it will scroll

Diffstat:
Msrc/subsystem.py | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/subsystem.py b/src/subsystem.py @@ -195,10 +195,16 @@ class GameCamera(GameSubsystem): """ Move the offset by the given relative offset. Speed can also be increased or decreased by - passing a multiple here. - """ - changex = rel_offset[0] * speed_multiple - changey = rel_offset[1] * speed_multiple + passing a multiple here. Handles not moving + the camera view outside of game screen + completely. + """ + changex = 0 + changey = 0 + if not ((self.camera_surface_offset[0] <= -(SCREEN_WIDTH / 2) and rel_offset[0] < 0) or (self.camera_surface_offset[0] >= (SCREEN_WIDTH / 2) and rel_offset[0] > 0)): + changex = rel_offset[0] * speed_multiple + if not ((self.camera_surface_offset[1] <= -SCREEN_HEIGHT and rel_offset[1] < 0) or (self.camera_surface_offset[1] >= (SCREEN_HEIGHT / 2) and rel_offset[1] > 0)): + changey = rel_offset[1] * speed_multiple self.camera_surface_offset = (self.camera_surface_offset[0] + changex, self.camera_surface_offset[1] + changey) def update_camera(self, surface = None):