-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgridRenderer.py
More file actions
23 lines (19 loc) · 1.03 KB
/
gridRenderer.py
File metadata and controls
23 lines (19 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from Viron.src.main.python.preponderous.viron.models.grid import Grid
from Viron.src.main.python.preponderous.viron.services.locationService import LocationService
from graphik import Graphik
from locationRenderer import LocationRenderer
class GridRenderer:
def __init__(self, graphik: Graphik, url: str, port: int):
self.graphik = graphik
self.location_service = LocationService(url, port)
self.location_renderer = LocationRenderer(graphik)
self.locations_cache = {}
def draw(self, grid: Grid):
grid_id = grid.get_grid_id()
if grid_id not in self.locations_cache:
self.locations_cache[grid_id] = self.location_service.get_locations_in_grid(grid_id)
locations = self.locations_cache[grid_id]
width = int(self.graphik.getGameDisplay().get_width() / grid.get_columns())
height = int(self.graphik.getGameDisplay().get_height() / grid.get_rows())
for location in locations:
self.location_renderer.draw(location, width, height)