now we need to fix perfomance in physics before merging / syncing / pushing anything to master
71 lines
2.7 KiB
Python
71 lines
2.7 KiB
Python
"""
|
|
#File Name: settings.py
|
|
|
|
Global settings and imports for the project.
|
|
|
|
This module defines various settings for the game engine, such as enabling or disabling the cursor, glow effect, gas effect, debug mode, and FPS display. It also provides a function to load particle properties from a JSON file.
|
|
|
|
The `engine_settings` dictionary contains the configurable settings for the game engine. These settings can be used to customize the behavior of the game.
|
|
|
|
The `load_particle_properties()` function attempts to load particle properties from a 'particles.json' file. If the file is not found or the JSON data is invalid, it returns an empty dictionary.
|
|
|
|
The `particle_properties` variable is initialized by calling `load_particle_properties()` when the module is imported.
|
|
"""
|
|
import cProfile
|
|
import pstats
|
|
import sys
|
|
import os
|
|
import pygame
|
|
import json
|
|
import random
|
|
import time
|
|
import numpy as np
|
|
|
|
engine_settings = {
|
|
'pause_sim': True,
|
|
'enable_cursor': True,
|
|
'enable_glow': False,
|
|
'enable_gas_effect': True,
|
|
'enable_debug': True,
|
|
'enable_fps': True,
|
|
'enable_WVisuals': False,
|
|
'enable_PVisuals': False,
|
|
'enable_TempVisuals': False,
|
|
'outerwall': False,
|
|
# 'settings': True/False
|
|
}
|
|
# For particles.json loading in settings.py:
|
|
particles_path = os.path.join(os.path.dirname(__file__), '..', 'part', 'particles.json')
|
|
|
|
|
|
# Load particle properties from JSON file
|
|
def load_particle_properties():
|
|
particle_data = {}
|
|
parts_path = os.path.join(os.path.dirname(__file__), '..', 'part')
|
|
|
|
def scan_directory(directory):
|
|
for root, dirs, files in os.walk(directory):
|
|
for file in files:
|
|
if file.endswith('.json'):
|
|
file_path = os.path.join(root, file)
|
|
try:
|
|
with open(file_path, 'r') as f:
|
|
mod_data = json.load(f)
|
|
relative_path = os.path.relpath(file_path, parts_path)
|
|
print(f"Loading particles from: {relative_path}")
|
|
particle_data.update(mod_data)
|
|
print(f"Loaded {len(mod_data)} particles from {relative_path}")
|
|
except (FileNotFoundError, json.JSONDecodeError) as e:
|
|
print(f"Error loading {file_path}: {e}")
|
|
|
|
if os.path.exists(parts_path):
|
|
scan_directory(parts_path)
|
|
else:
|
|
print(f"Parts directory not found at {parts_path}")
|
|
|
|
return particle_data
|
|
# Load particle properties once when module is imported
|
|
particle_properties = load_particle_properties()
|
|
__all__ = ['pygame', 'np', 'random', 'time', 'engine_settings', 'particle_properties', 'cProfile', 'pstats', 'sys', 'os']
|
|
|