TunnelRaidersGame Overview TunnelRaidersGame is a JavaFX-based 2D game inspired by the classic Dig Dug and enhanced with a Tower Defense mode. Developed by Mohammad Sanei, this project combines retro-style gameplay with modern mechanics, built using JavaFX 16 and Maven for dependency management and build automation. The game features a grid-based environment where players can dig tunnels, defeat enemies, and engage in a strategic tower defense mode. Features
Classic Dig Dug Gameplay: Navigate a grid-based map, digging tunnels to move through the environment. Defeat enemies (e.g., Pooka and Fygar) using a pump mechanism to inflate and eliminate them. Collect points and avoid obstacles like rocks that can fall and crush enemies or the player.
Tower Defense Mode: A U-shaped path where enemies spawn at a starting point and move toward an exit. Players can place turrets on the map's edges (yellow filler areas) by left-clicking to shoot bullets at enemies. Game timer set to 90 seconds with win/lose conditions: Win: Fewer than 5 enemies reach the exit. Lose: 5 or more enemies escape.
Enemies move at a fixed speed, and turrets automatically fire at enemies within a range of 6 grid cells.
Dynamic Map System: Grid-based map with customizable constructors and fillers (e.g., yellow walls, empty paths). Pathfinding for enemies in the tower defense mode using a precomputed U-shaped path.
Sound Effects: Integrated sound effects for actions like inflating enemies or shooting bullets, managed via a SoundManager class.
Resource Generation: Custom PNG generation for game assets (e.g., bullet.png, projectile.png) using JavaFX Canvas and SwingFXUtils.
Extensible Design: Modular architecture allowing for future level-based expansions and additional game modes. Support for multiple game objects (GameObject, Sprite, Enemy, Turret, Bullet) with collision detection and movement logic.
Project Structure
Package: com.tunnelgame core: Core game mechanics (e.g., GameObject, Map, SoundManager). towerDefense: Tower defense mode components (Enemy, Turret, Bullet, TowerDefenseEngine). models: Specific game models (e.g., Balloon for enemies).
Resources: Located in src/main/resources/assets/ (images, sounds). PNG files for sprites (e.g., bullet.png, turret.png) generated via utility classes like BulletImageGenerator.
Main Class: com.tunnelgame.TunnelRaidersGameApp
Prerequisites
Java: JDK 11 or higher Maven: 3.6.3 or higher JavaFX: Version 16 IDE: IntelliJ IDEA recommended for development and debugging
Setup and Installation
Clone the Repository:git clone cd TunnelRaidersGame
Install Dependencies:mvn clean install
Generate Assets (if needed): Run the BulletImageGenerator to create bullet.png:java -cp target/classes com.tunnelgame.towerDefense.BulletImageGenerator
Ensure generated PNG files are in src/main/resources/assets/.
Run the Game:mvn clean javafx:run
How to Play
Dig Dug Mode: Use arrow keys to move the player and dig tunnels. Press a key (e.g., Space) to use the pump to inflate enemies. Avoid falling rocks and defeat all enemies to progress.
Tower Defense Mode: Click the "Tower Defense" button (if implemented in the main menu) to start. Left-click on yellow areas around the U-shaped path to place turrets. Turrets automatically shoot bullets at enemies within range. Survive 90 seconds with fewer than 5 enemies escaping to win.
Controls: Arrow keys: Move player (Dig Dug mode). Left-click: Place turrets (Tower Defense mode). Other controls depend on additional implementations (e.g., Space for pump).
Development Notes
Developer: Mohammad Sanei Technology Stack: JavaFX 16 for rendering and UI. Maven for build and dependency management. JUnit, Hamcrest, Checkstyle, and PMD for testing and code quality.
Key Classes: GameObject: Base class for all game entities with position and collision logic. Map: Manages the grid-based game world and updates all objects. TowerDefenseEngine: Orchestrates the tower defense mode with enemy spawning, turret placement, and win/lose conditions. Turret and Bullet: Handle automated shooting mechanics in tower defense mode.
Known Issues: Previously resolved OutOfMemoryError by optimizing Bullet removal and reducing spawn rates. Ensure bullet.png exists in src/main/resources/assets/ to avoid IllegalArgumentException.
Future Improvements
Add a main menu with a dedicated button for launching the Tower Defense mode. Implement level-based progression for both Dig Dug and Tower Defense modes. Enhance enemy variety (e.g., different speeds, health) and turret upgrades. Add visual effects (e.g., animations for bullet impacts or enemy deaths). Optimize performance further by caching Image objects instead of creating new ImageView instances.
Contributing Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request with detailed descriptions of changes.
Student ID: 40322543
License This project is licensed under the MIT License. See the LICENSE file for details.