Commit Graph

36 Commits

Author SHA1 Message Date
Matteo Benedetto 62a65f599d Draw explosions and gas inside tunnel cells
Remove the is_hidden_in_tunnel() checks from Explosion.draw() and
Gas.draw() so explosions and gas clouds remain visible when their center
falls inside a tunnel cell. Logic already spawned them in tunnel cells,
but they were rendered invisible because the draw path returned early.
2026-06-16 21:56:22 +02:00
Matteo Benedetto 5afdf3705b Render rats inside internal tunnel passages
Previously Rat.draw() hid any rat whose center fell inside a tunnel.
The clipping helper only handled single-entrance cells and returned None
for internal passages/crossroads, causing rats to vanish entirely.

Now internal tunnel cells (those with 0 or 2+ open sides) draw the rat
normally so it remains visible while walking through the tunnel.
Single-entrance cells keep the partial clip effect.
Also fix the visible-ratio math for DOWN/RIGHT clipping: the old
formulas subtracted cell_size from a local coordinate, producing
zero or negative visibility.
2026-06-16 20:37:46 +02:00
Matteo Benedetto 2f8e3e8b28 Fix gas poisoning, explosion hit detection and render order
- Move gas poisoning from Gas.move() to Gas.collisions() so all rats are
  registered in the collision system before the poison query runs.
- Shrink gas and explosion bboxes so rats must be well inside the tile to
  be poisoned/killed.
- Use AABB overlap instead of partial_move threshold for gas poisoning.
- Draw mobile units first, then top-layer effects (gas, mines, bombs,
  explosions) so rats appear under the gas.
- Add draw_on_top hint to Unit base class and top-layer units.
2026-06-16 19:32:50 +02:00
Matteo Benedetto 3e8cd97fda Fix bomb explosions not killing rats and remove tracked pycache
- Move Timer explosion from move() to collisions() so all units are
  registered in the collision system before the kill query runs.
- Explosion units now set a bbox and kill rats that touch them.
- Guard Rat.draw() so dead rats are not drawn.
- Remove units/__pycache__ files from tracking.
2026-06-16 19:15:35 +02:00
John Doe c7ed24483d Add comprehensive test suite for game mechanics and level handling
- Introduced `test_final_level_flow.py` to validate final level transitions and game end scenarios.
- Created `test_game_over_flow.py` to ensure game over conditions trigger correctly based on rat counts.
- Implemented `test_keybindings.py` to verify keybinding configurations and their context-specific actions.
- Developed `test_level_editor.py` to assess level editor functionalities and layout computations.
- Added `test_level_io.py` for testing level data serialization and deserialization.
- Established `test_loop_logic_parity.py` to ensure consistent game state across multiple simulation runs.
- Created `test_non_regression.py` to simulate game behavior and capture states for future verification.
- Implemented `test_verify.py` to compare current game states against a golden master for regression detection.
2026-05-19 22:18:43 +02:00
John Doe 486cd6b7c5 Add non-regression test states and Bluetooth diagnostic script
- Introduced a new JSON file containing non-regression test states with detailed unit information, including positions, ages, and movement directions across multiple frames.
- Added a shell script for Bluetooth diagnostics that checks system information, Bluetooth binaries, running processes, D-Bus status, Bluetooth controller details, and audio stack status, providing a comprehensive overview for troubleshooting.
2026-05-17 23:36:24 +02:00
John Doe d32d2cd79c Refine start menu difficulty and preview workflow 2026-05-08 18:26:55 +02:00
John Doe 509b3433b8 Refactor rendering logic in MiceMaze and Rat classes for improved clarity and efficiency 2026-04-14 12:15:16 +02:00
John Doe b243cf04d3 Add explosion stage 1 PNG assets for all directions
- Added BMP_1_EXPLOSION_DOWN.png to original and preview directories.
- Added BMP_1_EXPLOSION_LEFT.png to original and preview directories.
- Added BMP_1_EXPLOSION_RIGHT.png to original and preview directories.
- Added BMP_1_EXPLOSION_UP.png to original and preview directories.

These assets are part of the explosion animation for the game, enhancing visual effects during gameplay.
2026-04-14 11:24:16 +02:00
John Doe b60ffd87aa Refactor code structure for improved readability and maintainability 2026-03-28 16:05:08 +01:00
John Doe 02202e4d3d Add new PNG images for clean and preview outputs
- Added `image_clean.png` to the output directory for the clean image representation.
- Added `image_clean_preview.png` for the preview of the clean image.
- Introduced `image_svg_clean.png` for the SVG clean image representation.
2026-03-27 23:40:27 +01:00
John Doe b4224ed3a1 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
2025-10-24 20:04:26 +02:00
John Doe 12836dd2d2 Implement optimized collision detection system using NumPy
- Introduced a hybrid collision detection approach that utilizes NumPy for vectorized operations, improving performance for games with many entities (200+).
- Added a spatial grid for efficient lookups and AABB (Axis-Aligned Bounding Box) collision detection.
- Implemented a new `CollisionSystem` class with methods for registering units, checking collisions, and managing spatial data.
- Created performance tests to benchmark the new collision system against the old O(n²) method, demonstrating significant speed improvements.
- Updated existing code to integrate the new collision detection system and ensure compatibility with game logic.
2025-10-24 19:13:30 +02:00
Matteo Benedetto 47028c95ae Implement main menu, profile list, and profile stats screens; add screen manager and user profile integration 2025-08-24 22:13:00 +02:00
Matteo Benedetto c004edef8f Update asset loading to include transparent color and adjust white flash timing; enhance nuclear bomb scoring and gas unit die method 2025-08-21 19:00:32 +02:00
Matteo Benedetto cbb60a19d9 Implement Score API Client and User Profile Integration
- Added ScoreAPIClient for communication with the Mice Game Score API, including methods for user signup, score submission, and leaderboard retrieval.
- Developed a simple profile manager demo to showcase user profile management and API integration.
- Created a test script for the Score API to validate all endpoints and functionality.
- Introduced UserProfileIntegration to manage user profiles, including local storage and API synchronization.
- Added a JSON file for user profiles with sample data for testing and demonstration purposes.
2025-08-21 17:02:41 +02:00
Matteo Benedetto 265af1832d Fix unit position retrieval in Rat class to use correct game state 2025-08-20 16:57:58 +02:00
Matteo Benedetto 17e5abc7df Final 2.0 2025-08-20 16:43:16 +02:00
Matteo Benedetto 8451ac7913 Refactor keybindings configuration and remove obsolete JSON files 2025-08-19 23:21:37 +02:00
Matteo Benedetto 30c592e138 Add KeyTester class for key press and release handling 2025-08-18 23:25:17 +02:00
Matteo Benedetto 8a32aad877 OK 2025-08-17 18:49:07 +02:00
Matteo Benedetto c35fc9f1f7 mine implementation 2025-08-14 16:53:15 +02:00
Matteo Benedetto 243bb6d9bd Enhance blood stain mechanics: add dynamic blood surface generation and integrate blood stains into game rendering 2025-08-13 23:30:43 +02:00
Matteo Benedetto 689b21bf65 Add unit tests for UnitFactory functionality and initialize units package 2025-08-13 20:36:51 +02:00
Matteo Benedetto 088ae02080 Refactor unit classes to reduce code duplication and improve maintainability
- Updated the Unit base class to include common attributes and methods for all units.
- Refactored Bomb, Point, and Rat classes to inherit from the new Unit class structure.
- Implemented a consistent die method across units for better cleanup.
- Removed redundant code in unit initialization and added specific attributes where necessary.
- Deleted obsolete configuration file and added a comprehensive architecture guide for future reference.
2025-08-13 17:42:45 +02:00
Matteo Benedetto aa907ed80a optimus-l1 2025-08-12 14:48:57 +02:00
Matteo Benedetto 98a9e5fb8b Aggiungi file di configurazione per i binding dei tasti e implementa la gestione degli input nel gioco 2024-12-27 19:03:04 +01:00
Matteo Benedetto 8b213761e4 Aggiungi la funzione count_rats per contare i ratti e aggiorna la logica di gioco; modifica la risoluzione nel file .env e gestisci eccezioni nel metodo pop di Timer 2024-12-23 17:16:05 +01:00
Matteo Benedetto 97038023d5 Aggiungi supporto per la risoluzione personalizzata e gestione della pausa nel gioco 2024-12-23 00:59:48 +01:00
Matteo Benedetto 3f513f1f19 Aggiungi gestione dei controlli da tastiera e migliora la logica di spawn delle unità 2024-12-22 18:12:45 +01:00
Matteo Benedetto acbd943b27 Aggiungi la classe Point e implementa la gestione delle esplosioni nel gioco 2024-12-17 00:14:02 +01:00
Matteo Benedetto d3936b5723 Riduci il ritardo di rendering da 50 a 10 ms, modifica il numero di ratti generati da 50 a 5 e aggiorna la tolleranza di sovrapposizione in base alla dimensione della cella 2024-12-15 22:02:57 +01:00
Matteo Benedetto 3ccffdca7d Modifica il sistema di rendering SDL e migliora la gestione delle unità nel gioco 2024-12-15 18:56:51 +01:00
Matteo Benedetto 0ad9cd47c6 Aggiungi supporto per SDL e sostituisci il sistema grafico basato su Tkinter 2024-12-14 23:00:22 +01:00
Matteo Benedetto a6a06d1d54 Aggiungi file .gitignore e nuove immagini BMP per il progetto Rat 2024-12-08 01:45:16 +01:00
Matteo Benedetto b89c4ae375 first commit 2024-12-05 23:30:16 +01:00