RAMRaiders-galaga-java is a modern, object-oriented Java project inspired by the classic Galaga arcade game (originally released in 1981) with a Star Wars theme.
The main goal of this project is to solidify Object-Oriented Programming (OOP) concepts through the development of a functional, modular, and maintainable game, featuring:
- Engaging graphical interface
- Advanced gameplay mechanics
- Use of multiple design patterns
- Star Wars themed assets
This repository is perfect for anyone who wants to learn or reinforce OOP concepts by applying them in a practical game development context.
POO_GALAGA is a modern version of the famous Galaga game, where the player controls a spaceship at the bottom of the screen, moving horizontally and shooting vertically to eliminate waves of enemies. The core objective is to survive as long as possible, facing increasingly challenging enemy formations and attack patterns. Projectiles are limited to simulate the classic Galaga feel. Enemies arrive in organized formations, perform lateral and zigzag movements, and can even descend in kamikaze style, trying to collide with the player or shoot directly.
The project applies several classic software design patterns to achieve flexibility, scalability, and maintainable code:
-
Strategy Pattern
Defines and encapsulates different algorithms for enemy behaviors. Interfaces likeIEnemyMovementandIAttackStrategyallow for multiple movement (e.g., circular, zigzag, kamikaze) and attack (e.g., linear, homing, group) strategies. TheEnemyBehaviorclass can dynamically switch strategies, enabling easy addition of new enemy behaviors without changing the core code. -
Bridge Pattern
Separates game logic from the graphical interface. TheGameManagerinteracts with the interface layer via theIGuiBridgeabstraction, so different GUI implementations (e.g.,SwingGui) can be swapped without impacting the core game logic. -
Observer Pattern (Partial)
Some enemies react to the player's position, simulating an observer relationship (e.g., homing attacks). While not a classical observer implementation, the architecture allows enemies to dynamically adapt to the player's state.
- Classic Arcade Gameplay: Player controls a spaceship that moves horizontally and shoots enemies above.
- Enemy Formations & Behaviors:
- Enemies move in organized formations, with lateral and zigzag patterns.
- Some perform kamikaze dives, while others shoot directly or in groups.
- Each enemy's behavior is managed by the
EnemyBehaviorclass and can be easily expanded.
- Attack Strategies:
- Direct attack (shooting at the player's current position).
- Patterned attacks (zigzag, V-shape, etc.).
- Group attacks (multiple enemies shooting at once).
- Precise Collision System:
- Uses circular or polygonal colliders for accurate collision detection.
- Player loses a life when hit; enemies are destroyed and award points when shot.
- Dynamic Difficulty:
- New attack patterns introduced as the game progresses.
- Increased frequency and size of enemy waves.
- Advanced Enemy AI:
- Some enemies "observe" and respond to the player's current position for smarter attacks and movements.
- Limited Shots:
- The number of active player projectiles is limited, simulating the original Galaga mechanics.
- Modern Codebase:
- Thread safety with
CopyOnWriteArrayList. - Modularized behaviors, interfaces, and managers.
- Scheduled executors for precise timing.
- Geometric calculations for movement and collision.
- Thread safety with
- Arrow Keys: Move player ship horizontally.
- Spacebar: Shoot.
- P: Pause game (if implemented).
- R: Restart game (if implemented).
- Mouse Right Click: Attack.
- Mouse Left Click: Dodge.
- C Key: Attack.
- X Key: Dodge.
POO_GALAGA/
├── src/
│ ├── assets/ # Game resources (audio and images)
│ ├── core/ # Core game logic and management
│ ├── geometry/ # Collision system and geometric shapes
│ ├── gui/ # Graphical interface and user input
│ └── test/ # Unit tests and visualizers
├── out/ # Compiled .class files
├── README.md
├── CONTRIBUTING.md # Contribution guidelines
└── CODE_OF_CONDUCT.md # Code of conduct
- GameManager: Central controller. Manages game state, coordinates objects and behaviors, controls score and collisions, integrates GUI and audio, and handles rendering layers.
- GameEngine: Game loop engine. Manages main loop, state updates, rendering, and thread synchronization.
- GameObject: Base class for all game objects, with transform (position, rotation, scale), collider, shape, and behavior.
- Behavior (abstract): Base for all behaviors.
- PlayerBehavior: Controls player actions.
- EnemyBehavior: Controls enemy logic and strategy.
- EnterOverTopMovement: Enters from the top.
- EnterSideMovement: Enters from the side.
- FlyCircleMovement: Circular motion.
- FlyLassoMovement: Lasso-shaped motion.
- ZigzagMovement: Zigzag motion.
- HomingShootAttack: Homing projectiles.
- LinearShootAttack: Straight-line shots.
- Group Attacks: Coordinated or zigzag group attacks.
- ImagesLoader: Loads/manages sprites & animations (supports GIF and static images, resource caching).
- AudioLoader & SoundEffects: Manages sound effects and background music with async audio system.
- Implements basic geometric shapes: circle, polygon, rectangle, triangle.
- SwingGui: Main interface.
- GamePanel: Rendering panel.
- InputEvent: Input event system.
- Java 8+
- Java Swing (or JavaFX, specify if different)
- Custom Assets: All graphical and sound resources in
assets/by Gabriel Pedroso. - Thread-Safety: Use of
CopyOnWriteArrayListfor safe concurrent operations. - Cross-platform: Compatible with Windows, Linux, and macOS.
- Recommended IDE: IntelliJ IDEA, Eclipse, VS Code (optional)
git clone https://github.com/kanekitakitos/POO_GALAGA.git
cd POO_GALAGAUsing command line:
javac -d bin src/**/*.javaOr use your preferred Java IDE to import and build the project.
java -cp bin MainReplace
Mainwith the actual name of your main class if different.
Note: If the game does not work properly after compiling (for example, if images or sounds are missing), you may need to manually copy the image and audio files from the
assets/folder to the output directory (bin/assetsor the equivalent folder used by your IDE). Make sure the resources are accessible at the path expected by the application.
- Fork the repository.
- Create a feature branch (
git checkout -b my-feature) - Commit your changes (
git commit -m 'feat: my new feature') - Push to your branch (
git push origin my-feature) - Open a Pull Request.
See CONTRIBUTING.md for more details and best practices.
Want to experience the classic before playing our modern version?
You can play the original Galaga (NES version) online here:
https://www.retrogames.cz/play_018-NES.php
This project is licensed under the "Educational Use Only License".
Use, copying, modification, and distribution are permitted for educational and non-commercial purposes only, as described in the LICENSE file.
Commercial use is prohibited without prior permission from the author.
- Documentation: Miguel Correia
- Assets (images, sounds, etc.): Gabriel Pedroso
- Author: kanekitakitos