Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raccoon-hero/threads-siege
A multithreaded arcade-style space defense game built with Java Swing, featuring real-time shooting mechanics, dynamic difficulty scaling, and responsive gameplay elements.
https://github.com/raccoon-hero/threads-siege
2d-game arcade-game concurrent-programming dynamic-difficulty java java-games multithreading semaphore space-shooter swing synchronization thread-management
Last synced: 4 days ago
JSON representation
A multithreaded arcade-style space defense game built with Java Swing, featuring real-time shooting mechanics, dynamic difficulty scaling, and responsive gameplay elements.
- Host: GitHub
- URL: https://github.com/raccoon-hero/threads-siege
- Owner: raccoon-hero
- License: gpl-3.0
- Created: 2024-12-16T17:06:05.000Z (6 days ago)
- Default Branch: main
- Last Pushed: 2024-12-16T17:10:18.000Z (6 days ago)
- Last Synced: 2024-12-16T18:23:59.726Z (6 days ago)
- Topics: 2d-game, arcade-game, concurrent-programming, dynamic-difficulty, java, java-games, multithreading, semaphore, space-shooter, swing, synchronization, thread-management
- Language: Java
- Homepage:
- Size: 37.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Threads Siege ๐
![Java](https://img.shields.io/badge/Java-8+-blue?logo=java&logoColor=white)
![Status](https://img.shields.io/badge/Status-Prototype-yellow)An under 500 lines of code prototype **Threads Siege** made for a subject in uni, an arcade-style space defense game built with **Java Swing**. Players use their spaceship cannon to shoot down incoming alien enemies while avoiding letting too many enemies slip through.
![Gameplay Screenshot](assets/gameplay-screenshot.png)
_**Screenshot 1.** Gameplay Screenshot (UI in Ukrainian)_โ ๏ธ **Expect bugs and unpolished gameplay.** Contributions, feedback, and suggestions are welcome to help refine this game.
---
## Features ๐
- **Multithreaded Mechanics**: Each enemy and bullet runs independently on its thread, allowing real-time movement and interaction.
- **Dynamic Difficulty Adjustment**: The number of active enemies and their spawn rate automatically increase as the game progresses, based on the player's score and elapsed time.
- **Collision-Based Scoring**: Bullets destroy enemies on contact, incrementing the score while missed enemies contribute to the game-over counter.
- **Limited Ammo**: Players can have only three active bullets at a time, managed using a semaphore for concurrency control.
- **Game State Feedback**: The UI dynamically updates to reflect the player's score and missed enemies, with win/lose conditions displayed at the game end.---
## Getting Started ๐ ๏ธ
### Prerequisites
Ensure you have the following installed:
- **Java 8** or higher
- Any Java IDE or a command-line terminal### Installation
1. **Clone the repository**:
```bash
git clone https://github.com/raccoon-hero/threads-siege.git
cd threads-siege
```2. **Compile the project**:
Using the terminal:
```bash
javac ThreadsSiege.java
```3. **Run the game**:
```bash
java ThreadsSiege
```---
## Controls ๐ฎ
- **Arrow Keys**: Move your cannon left and right.
- **Spacebar**: Shoot bullets (limited to three active bullets at a time).---
## Project Structure ๐
```plaintext
threads-siege/
โโโ assets/ # Assets for showcasing gameplay (e.g., screenshots)
โโโ ThreadsSiege.java # Main game file
โโโ README.md # Project Documentation (youโre here! :D)
```---
## Known Issues ๐พ
- **Thread Termination**: Active threads (e.g., enemies and bullets) are not guaranteed to terminate when the game exits, which may lead to memory leaks or lingering processes.
- **Concurrency Management**: Shared resources like `enemies` and `bullets` are manually synchronized, which could cause subtle bugs under certain conditions.
- **UI Scaling**: Game objects do not resize dynamically when the window size is changed, resulting in potential layout issues.
- **Repaint Performance**: Under heavy load, the UI may experience performance drops due to frequent updates and rendering of multiple threads.
- **Error Handling**: Exceptions such as `InterruptedException` are caught but not logged, which may hinder debugging.---
## Future Plans โฉ
- **Thread Management**: Implement a proper cleanup mechanism for threads to ensure they terminate cleanly when the game ends.
- **Improved Concurrency**: Replace manual synchronization with safer concurrent collections like `ConcurrentLinkedQueue` for managing enemies and bullets.
- **Customizable Settings**: Introduce configuration options for adjusting game parameters such as enemy speed, bullet speed, and spawn rates.
- **Graphics Scaling**: Add support for responsive scaling of game objects to adapt to window resizing.
- **Performance Optimization**: Profile and optimize repaint intervals to reduce lag during heavy gameplay.
- **Logging System**: Integrate basic logging to capture runtime exceptions and errors for debugging purposes.---
## Contributing ๐ค
1. Fork this repository.
2. Create a feature branch (`git checkout -b feature/amazing-feature`).
3. Commit your changes (`git commit -m 'Add some amazing feature'`).
4. Push to the branch (`git push origin feature/amazing-feature`).
5. Open a Pull Request.