v1.1: Performance optimizations and bug fixes

Major improvements:
- NumPy-based collision system supporting 200+ units (~3ms/frame)
- Spatial hashing with vectorized distance calculations
- 4-pass game loop ensuring correct collision timing
- Blood overlay system with pre-generated stain pool
- Cached render positions and viewport bounds
- Spawn protection preventing rats spawning on weapons

Bug fixes:
- Fixed bombs not killing rats (collision system timing)
- Fixed gas not affecting rats (collision system timing)
- Fixed rats spawning on weapons (added has_weapon_at check)
- Fixed AttributeError with Gas collisions (added isinstance check)
- Fixed blood stain transparency (RGBA + SDL_BLENDMODE_BLEND)
- Reduced point lifetime from 200 to 90 frames (~1.5s)
- Blood layer now clears on game restart

Technical changes:
- Added engine/collision_system.py with CollisionLayer enum
- Updated all units to use collision layers
- Pre-allocate NumPy arrays with capacity management
- Hybrid collision approach (<10 simple, ≥10 vectorized)
- Python 3.13 compatibility
This commit is contained in:
2025-10-24 20:04:26 +02:00
parent 12836dd2d2
commit b4224ed3a1
12 changed files with 619 additions and 135 deletions
+13
View File
@@ -26,6 +26,19 @@ ALWAYS:
Search web/documentation if unsure
Wait for user confirmation
TERMINAL COMMAND EXECUTION RULES
When executing scripts or tests in terminal:
1. ALWAYS use isBackground=false for test scripts and commands that produce output to analyze
2. WAIT for command completion before reading results
3. After running a test/benchmark, read terminal output with get_terminal_output before commenting
4. Never assume command success - always verify with actual output
Examples:
- ✓ run_in_terminal(..., isBackground=false) → wait → get_terminal_output → analyze
- ✗ run_in_terminal(..., isBackground=true) for tests (you won't see the output!)
CONSULTATION vs IMPLEMENTATION
When the user asks for advice, tips, or consultation: