Return to repo list

heart-of-gold

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

commit 3b35871ce323da07978b1ff6d4561ff16215fa75
parent 95bfb56e45f0b02f1849be72f21aa80ecf9b2e0d
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Fri, 30 Apr 2021 21:12:06 -0500

tightening up in scene and interface

Diffstat:
Msrc/interface.py | 22++++++++++++----------
Msrc/scene.py | 2+-
2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/interface.py b/src/interface.py @@ -302,19 +302,21 @@ class GameInterface(subsystem.GameSubsystem): # Position cursor in scrollable modes and/or scroll if self.game.control_mode in SCROLLABLE_TURN_MODES: # Move camera with keys - if self.camera_motions != [0, 0]: + if tuple(self.camera_motions) != (0, 0): self.camera.move_offset(self.camera_motions, SCROLL_SPEED) # Drag camera elif self.drag_camera: - sg = lambda x: int((x > 0) - (x < 0)) - camdiff = [self.drag_camera_from_pos[0] - mouseraw[0], self.drag_camera_from_pos[1] - mouseraw[1]] - for k in (0, 1): - if abs(camdiff[k]) < 33: - camdiff[k] = 0 - else: - camdiff[k] = sg(camdiff[k]) - if camdiff != (0, 0): - self.camera.move_offset(tuple(camdiff), SCROLL_SPEED) + camdiff = (self.drag_camera_from_pos[0] - mouseraw[0], self.drag_camera_from_pos[1] - mouseraw[1]) + if abs(camdiff[0]) > 3 or abs(camdiff[1]) > 3: + sg = lambda x: int((x > 0) - (x < 0)) + dragdir = [(SCREEN_WIDTH // 2) - mouseraw[0], (SCREEN_HEIGHT // 2) - mouseraw[1]] + for k in (0, 1): + if abs(dragdir[k]) < 80: + dragdir[k] = 0 + else: + dragdir[k] = sg(dragdir[k]) + if dragdir != (0, 0): + self.camera.move_offset(tuple(dragdir), SCROLL_SPEED) # Position cursor if tilepos != None: self.bus.perform_piece_manager_position_tile_cursor((tilepos[0], tilepos[1])) diff --git a/src/scene.py b/src/scene.py @@ -216,7 +216,7 @@ class StillScene(object): self.current_font = self.fonts[self.script[self.script_index]["line_font"]] self.current_name_font = self.fonts[self.script[self.script_index]["name_font"]] self.current_font_height = self.current_font.get_height() - self.max_line = int((3 * SCREEN_WIDTH) / self.current_font_height) + self.max_line = int((3 * SCREEN_WIDTH) // self.current_font_height) - 4 self.total_lines = int(self.text_area_height / self.current_font_height) self.current_voice = self.script[self.script_index]["voice"] self.current_text_string = self.script[self.script_index]["line"]