/
ap1k
/
PyGame_Practice
Обзор
Документация
Войти
/
ap1k
/
PyGame_Practice
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/utils/config.py
99 строк
3 KB
Roman
The all game
27 май 2025, 15:26
27 май 2025, 15:26
4ea7de9
Код
Авторство
О чём код?
""" Config class - stores game configuration Implements the Singleton pattern to ensure only one config instance exists """ class Config: """ Game configuration class implementing Singleton pattern """ _instance = None def __new__(cls): if cls._instance is None: cls._instance = super(Config, cls).__new__(cls) cls._instance._initialized = False return cls._instance def __init__(self): if self._initialized: return # Screen settings self.screen_width = 800 self.screen_height = 600 self.fps = 60 self.title = "Space Defender" # Player settings self.player_speed = 6 self.player_lives = 3 self.player_acceleration = 0.2 self.player_deceleration = 0.1 self.player_max_speed = 8 # Weapon settings self.weapon_cooldown = { 0: 500, # Basic weapon (cooldown in milliseconds) 1: 300, # Rapid fire weapon 2: 1000 # Powerful weapon } self.weapon_damage = { 0: 10, # Basic weapon damage 1: 5, # Rapid fire weapon damage 2: 25 # Powerful weapon damage } self.weapon_names = { 0: "Basic Laser", 1: "Rapid Blaster", 2: "Power Cannon" } self.weapon_colors = { 0: (0, 255, 255), # Cyan for basic 1: (0, 255, 0), # Green for rapid 2: (255, 165, 0) # Orange for power } # Enemy settings self.enemy_spawn_rate = 2000 # Time between enemy spawns in milliseconds self.enemy_types = { "basic": { "speed": 2, "health": 30, "damage": 10, "score": 10 }, "fast": { "speed": 4, "health": 15, "damage": 5, "score": 15 }, "tank": { "speed": 1, "health": 60, "damage": 15, "score": 20 } } # Colors self.colors = { "black": (0, 0, 0), "white": (255, 255, 255), "red": (255, 0, 0), "green": (0, 255, 0), "blue": (0, 0, 255), "yellow": (255, 255, 0), "purple": (128, 0, 128), "cyan": (0, 255, 255), "orange": (255, 165, 0), "dark_blue": (25, 25, 112), "light_blue": (173, 216, 230), "gray": (128, 128, 128), "light_gray": (211, 211, 211), "dark_gray": (64, 64, 64), "transparent_black": (0, 0, 0, 128) } self._initialized = True