44"""
55Core engine systems and base components.
66"""
7+ from pathlib import Path
78
89from importlib .machinery import ModuleSpec
910from types import ModuleType
@@ -404,7 +405,12 @@ def __init__(
404405 GP_BASE_PATH : str ,
405406 cursor_visible : bool = True ,
406407 fullscreen : bool = False ,
407- icon_path : Optional [str ] = None ,
408+ icon_path : Optional [
409+ Union [
410+ str ,
411+ Path
412+ ]
413+ ] = None ,
408414 IS_EDITOR : bool = False ,
409415 ) -> None :
410416 """
@@ -416,7 +422,7 @@ def __init__(
416422 height (int): Window height in pixels. Defaults to 600.
417423 cursor_visible (bool): Whether the mouse cursor is visible. Defaults to True.
418424 fullscreen (bool): Whether to start in fullscreen mode. Defaults to False.
419- icon_path (Optional[str]): Path to window icon image. Defaults to None.
425+ icon_path (Optional[str | Path ]): Path to window icon image. Defaults to None.
420426 IS_EDITOR (bool): Whether running in editor mode. Defaults to False.
421427 GP_BASE_PATH (str): Base path for game assets
422428
@@ -443,7 +449,8 @@ def __init__(
443449 if not IS_EDITOR and sys .stdout is not None and sys .stdout .isatty ():
444450 print (colorama .ansi .set_title (title ), end = "" )
445451
446- self .set_icon (icon_path )
452+ if icon_path is not None :
453+ self .set_icon (icon_path )
447454
448455 pygame .mouse .set_visible (cursor_visible )
449456 self .clock : pygame .time .Clock = pygame .time .Clock ()
@@ -528,23 +535,22 @@ def add_to_current_scene(self, entity: Entity) -> None:
528535
529536 self .scenes [self .current_scene ].add (entity )
530537
531- def set_icon (self , icon_path : Optional [str ]) -> None :
538+ def set_icon (self , icon_path : Union [str , Path ]) -> None :
532539 """
533540 Set the icon for the game window.
534541
535542 Args:
536- icon_path (Optional[ str] ): The path to the icon file.
543+ icon_path (str | Path ): The path to the icon file.
537544 """
538545
539- if icon_path is not None :
540- try :
541- image : pygame .Surface = pygame .image .load (
542- os .path .join (self .GP_BASE_PATH , icon_path )
543- )
544- image = image .convert_alpha ()
545- pygame .display .set_icon (image )
546- except (pygame .error , FileNotFoundError ) as e :
547- logger (f"Error loading icon: { e } " , status = LoggerStatus .WARNING )
546+ try :
547+ image : pygame .Surface = pygame .image .load (
548+ os .path .join (self .GP_BASE_PATH , icon_path )
549+ )
550+ image = image .convert_alpha ()
551+ pygame .display .set_icon (image )
552+ except (pygame .error , FileNotFoundError ) as e :
553+ logger (f"Error loading icon: { e } " , status = LoggerStatus .WARNING )
548554
549555 def updateall (self , dt : float , / , exclude : Optional [Scene ] = None ) -> None :
550556 """
0 commit comments