refactor: fix formatting and set game window title to "Silent FH"
This commit is contained in:
+10
-9
@@ -46,6 +46,7 @@ class Game:
|
|||||||
pygame.init()
|
pygame.init()
|
||||||
self.screen = pygame.display.set_mode((screen_w, screen_h))
|
self.screen = pygame.display.set_mode((screen_w, screen_h))
|
||||||
self.clock = pygame.time.Clock()
|
self.clock = pygame.time.Clock()
|
||||||
|
pygame.display.set_caption("Silent FH")
|
||||||
self.font = pygame.font.SysFont("monospace", 22, bold=True)
|
self.font = pygame.font.SysFont("monospace", 22, bold=True)
|
||||||
self.item_font = pygame.font.SysFont("Arial", 16, bold=True)
|
self.item_font = pygame.font.SysFont("Arial", 16, bold=True)
|
||||||
self.running = True
|
self.running = True
|
||||||
@@ -172,7 +173,7 @@ class Game:
|
|||||||
- (keys[pygame.K_LEFT] or keys[pygame.K_a]),
|
- (keys[pygame.K_LEFT] or keys[pygame.K_a]),
|
||||||
(keys[pygame.K_DOWN] or keys[pygame.K_s])
|
(keys[pygame.K_DOWN] or keys[pygame.K_s])
|
||||||
- (keys[pygame.K_UP] or keys[pygame.K_w]),
|
- (keys[pygame.K_UP] or keys[pygame.K_w]),
|
||||||
)
|
)
|
||||||
|
|
||||||
if movement.length_squared() == 0:
|
if movement.length_squared() == 0:
|
||||||
return movement
|
return movement
|
||||||
@@ -190,9 +191,9 @@ class Game:
|
|||||||
return self.map.is_accessible(column, row)
|
return self.map.is_accessible(column, row)
|
||||||
|
|
||||||
def is_player_at_desk(
|
def is_player_at_desk(
|
||||||
self,
|
self,
|
||||||
player_rect: Optional[pygame.Rect] = None,
|
player_rect: Optional[pygame.Rect] = None,
|
||||||
room_rect: Optional[pygame.Rect] = None,
|
room_rect: Optional[pygame.Rect] = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Return True while the player's hitbox touches a desk in the current room."""
|
"""Return True while the player's hitbox touches a desk in the current room."""
|
||||||
|
|
||||||
@@ -206,9 +207,9 @@ class Game:
|
|||||||
return any(desk.check_collision(player_rect) for desk in self.map.get_desks_for_room(room_rect))
|
return any(desk.check_collision(player_rect) for desk in self.map.get_desks_for_room(room_rect))
|
||||||
|
|
||||||
def update_tower(
|
def update_tower(
|
||||||
self,
|
self,
|
||||||
room_rect: Optional[pygame.Rect],
|
room_rect: Optional[pygame.Rect],
|
||||||
is_at_desk: bool,
|
is_at_desk: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Spawn a tower after the player studies at a table, then let it attack."""
|
"""Spawn a tower after the player studies at a table, then let it attack."""
|
||||||
|
|
||||||
@@ -358,8 +359,8 @@ class Game:
|
|||||||
tile_size,
|
tile_size,
|
||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
room_rect.left <= tile_rect.centerx <= room_rect.right
|
room_rect.left <= tile_rect.centerx <= room_rect.right
|
||||||
and room_rect.bottom <= tile_rect.centery <= room_rect.bottom + 2 * tile_size
|
and room_rect.bottom <= tile_rect.centery <= room_rect.bottom + 2 * tile_size
|
||||||
):
|
):
|
||||||
door_tiles.append(tile_rect)
|
door_tiles.append(tile_rect)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user