commit 930b7a09cdc529b1558001faa75369f8004224b3
parent 533606707a318a0dcca77011e09a51868c045fb5
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Thu, 10 Jun 2021 15:08:33 -0500
clicking where the tiles are projected to
Diffstat:
5 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/board.py b/src/board.py
@@ -76,7 +76,7 @@ class BoardManager(manager.Manager):
for layer in self.current_board.tmx_data.visible_layers:
if isinstance(layer, pytmx.TiledTileLayer):
for x, y, gid in layer:
- if pos[0] >= x * w and pos[0] < (x + 1) * w and pos[1] >= y * w and pos[1] < (y + 1) * w:
+ if pos[0] >= x * w * TILE_SCALE_FACTOR and pos[0] < (x + 1) * w * TILE_SCALE_FACTOR and pos[1] >= y * w * TILE_SCALE_FACTOR and pos[1] < (y + 1) * w * TILE_SCALE_FACTOR:
return (x, y, gid)
return None
diff --git a/src/bus.py b/src/bus.py
@@ -133,6 +133,8 @@ class ManagerBus(Bus):
# Collection of managers
self.elements = {}
+ # TODO: Redundant? The wrong way to do this??
+ self.managers = {}
# Recording
if self.bus != None:
@@ -175,4 +177,5 @@ class ManagerBus(Bus):
# check_for_* = return something else
# Performs: All callable non-return behaviors of managers.
-
+ def perform_board_manager_get_tile_at_position(self, mousepos):
+ self.managers["board_manager"].get_tile_at_position(mousepos)
diff --git a/src/camera.py b/src/camera.py
@@ -30,6 +30,7 @@ class GameCamera(subsystem.GameSubsystem):
self.camera_surface = pygame.Surface((0, 0)).convert() # This surface is initialized whenever a new map or other game area is loaded
self.camera_surface_rect = self.camera_surface.get_rect()
self.camera_surface_offset = (0, 0) # The rect topleft is never changed; rather, this value is used by game to draw the camera surface at an offset
+ self.camera_surface_base_dimensions = (0, 0)
# Recording
if self.bus != None:
@@ -44,6 +45,7 @@ class GameCamera(subsystem.GameSubsystem):
self.camera_surface = pygame.Surface(dimensions).convert()
self.camera_surface_rect = self.camera_surface.get_rect()
self.camera_surface_offset = init_offset
+ self.camera_surface_base_dimensions = dimensions
def move_offset(self, rel_offset, speed_multiple = 1):
"""
@@ -78,7 +80,9 @@ class GameCamera(subsystem.GameSubsystem):
Update and draw the camera contents.
"""
if surface != None:
- surface.blit(self.camera_surface, self.camera_surface_offset)
+ # NOTE: This probably won't work. Think of collision scaling issues...
+ # On the other hand, it would be ideal for keeping all resolutions in line...
+ surface.blit(pygame.transform.scale(self.camera_surface, (self.camera_surface_base_dimensions[0] * TILE_SCALE_FACTOR, self.camera_surface_base_dimensions[1] * TILE_SCALE_FACTOR)), self.camera_surface_offset)
def update_fetch_data(self):
"""
diff --git a/src/interface.py b/src/interface.py
@@ -103,6 +103,10 @@ class GameInterface(subsystem.GameSubsystem):
self.left_double_clicking = True
self.left_double_click_timer = 0
+ # Handle clicking
+ if self.game.state_mode == STATE_MODES.Location_Mode:
+ self.manager_bus.perform_board_manager_get_tile_at_position(mouseraw)
+
# Handle right-click
elif event.button == 3:
diff --git a/src/manager.py b/src/manager.py
@@ -54,6 +54,10 @@ class Manager(subsystem.GameSubsystem):
self._activated = True
self._effectual = False
+ # Managers should record themselves in the manager bus for performs
+ # TODO: Redundant? The wrong way to do this??
+ self.bus.managers[self.name] = self
+
def expose(self):
"""
Expose info about this object to the ManagerBus