-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (36 loc) · 1.19 KB
/
main.py
File metadata and controls
43 lines (36 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pygame
import yaml
import sys
import os
from engine.scene_manager import SceneManager
def load_config(path="config.yaml"):
if not os.path.exists(path):
raise FileNotFoundError(f"Config file not found: {path}")
with open(path, 'r') as f:
return yaml.safe_load(f)
class Launcher:
def __init__(self, config):
self.config = config
self.screen = None
self.scene_manager = None
def init_window(self):
width = self.config.get("window", {}).get("width", 800)
height = self.config.get("window", {}).get("height", 600)
title = self.config.get("window", {}).get("title", "game-engine")
pygame.init()
self.screen = pygame.display.set_mode((width, height))
pygame.display.set_caption(title)
def run(self):
print("🚀 Launching game-engine...")
self.init_window()
self.scene_manager = SceneManager(self.screen, self.config)
self.scene_manager.run()
if __name__ == "__main__":
try:
config = load_config()
launcher = Launcher(config)
launcher.run()
except Exception as e:
print("❌ Game crashed:", e)
pygame.quit()
sys.exit(1)