UPDATE: Window resizable
This commit is contained in:
@@ -14,6 +14,10 @@ class MapCoordController:
|
||||
self.map_width = map_max_x - map_min_x
|
||||
self.map_height = map_max_y - map_min_y
|
||||
|
||||
def update_screen_size(self, screen_width: int, screen_height: int):
|
||||
self.screen_width = screen_width
|
||||
self.screen_height = screen_height
|
||||
|
||||
def screen_to_map(self, x, y):
|
||||
mapped_x = mapped_value(x, 0, self.screen_width, self.map_min_x, self.map_max_x)
|
||||
mapped_y = mapped_value(y, 0, self.screen_height, self.map_min_y, self.map_max_y)
|
||||
|
||||
@@ -10,7 +10,7 @@ FPS = 60
|
||||
class Game:
|
||||
def __init__(self, match: Match):
|
||||
pygame.init()
|
||||
self.screen = pygame.display.set_mode((WIDTH, HEIGHT))
|
||||
self.screen = pygame.display.set_mode((WIDTH, HEIGHT), pygame.RESIZABLE)
|
||||
self.font = pygame.font.Font(None, 36)
|
||||
self.small_font = pygame.font.Font(None, 15)
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ class Renderer:
|
||||
self.top_left_x, self.bottom_right_x, self.top_left_y, self.bottom_right_y)
|
||||
def render_players(self):
|
||||
"""Draws everything on screen."""
|
||||
self.map_coord_controller.update_screen_size(self.screen.get_width(), self.screen.get_height())
|
||||
for player in self.match.get_players():
|
||||
if player.dead:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user