A modern refactoring of the classic Java Space Invaders arcade game, enhanced using Creational, Structural, and Behavioral Software Design Patterns as part of the CCSW 413 โ Software Design Patterns course at the University of Jeddah.
This project improves the original gameโs architecture by making it modular, extensible, memory-efficient, and easier to maintain, while preserving the original gameplay experience.
This application is based on the iconic Space Invaders (1978) game.
The player controls a cannon and defends Earth from waves of alien invaders.
To elevate the code quality and architecture, we applied the following design patterns across three phases:
- Used for cloning Alien objects instead of repeatedly instantiating new ones.
- Reduces redundancy and simplifies creation of multiple similar aliens.
- Introduced a
BoardFactoryto handle creation of game elements (player, aliens, bullets). - Decouples object creation from the game logic.
- Implemented
SpriteManagerto cache and reuse sprite images. - Ensures each sprite is loaded once โ memory and performance optimization.
- Created
AlienDecoratorandStrongAliento add HP and extra behavior to aliens. - Allows dynamic addition of features without modifying the original Alien class.
- Introduced
AlienTypeandAlienTypeFactoryto share intrinsic alien data (appearance, base stats). - Reduces memory usage significantly when rendering many aliens.
- Implemented a game Status Bar showing:
- Score
- Aliens defeated
- Remaining time
- Status bar visually responds to events (low time, win, game over).
- Refactored the game phases into separate states:
- Main Menu
- Level 1
- Level 2
- Game Won
- Game Over
- Each state encapsulates its own behavior โ easier to add new levels.
/src /game
- Board.java
- SpaceInvaders.java
- SpriteManager.java // Singleton
- GameState classes // State Pattern
- Observer interfaces // Observer Pattern
- Factory classes // Factory Method
- AlienDecorator... // Decorator Pattern
- AlienTypeFactory... // Flyweight Pattern /report
Detailed diagrams for all phases can be found in the project report:
- Original class diagrams
- Refactored diagrams (Creational, Structural, Behavioral)
- Hajar Habiburahman
- Rawan Tallha
- Rital Shilli
College of Computer Science and Engineering
Department of Software Engineering
- Clone the repository:
git clone https://github.com/RitalShilli3/java-space-invaders



