REFACTOR to be more modular
This commit is contained in:
24
render/map_renderer.py
Normal file
24
render/map_renderer.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import pygame
|
||||
from utils.json_object import JSONObject
|
||||
from controllers.map_coord_controller import MapCoordController
|
||||
|
||||
class MapRenderer:
|
||||
def __init__(self, screen, map_data_path, map_image_path):
|
||||
self.screen = screen
|
||||
self.map_data_path = map_data_path
|
||||
self.map_image_path = map_image_path
|
||||
|
||||
self.map_image = pygame.image.load(self.map_image_path)
|
||||
|
||||
def _load_json(self, path: str) -> JSONObject:
|
||||
try:
|
||||
return JSONObject(path)
|
||||
except FileNotFoundError:
|
||||
raise NotImplementedError(f"Map not implemented.")
|
||||
|
||||
def render(self):
|
||||
# Scale and rotate map image
|
||||
self.map_image = pygame.transform.scale(self.map_image, (self.screen.get_width(), self.screen.get_height()))
|
||||
|
||||
# Draw map image
|
||||
self.screen.blit(self.map_image, (0, 0))
|
||||
Reference in New Issue
Block a user