Skip to content

4bush/Game

Repository files navigation

Star Defender - Space Shooter

Star Defender is a 2D vertical arcade space shooter built with Java and libGDX/LWJGL3 for a Software Design Patterns course project. The player controls a ship, destroys endless enemy waves, collects power-ups, survives boss fights, and tries to reach the highest possible score.

Current Status

Playable course build, documentation updated for the current implementation.

The project is beyond the original Day 3 README state. The current code includes the main menu, gameplay state, pause state, game-over state, multiple weapon strategies, power-ups, boss encounter, parallax background, HUD, and an event system.

Not yet implemented: saved high score, audio/music, and active mouse-driven menu buttons.

Tech Stack

  • Java 8 target compatibility
  • libGDX
  • LWJGL3 desktop backend
  • Gradle

Core Gameplay

The game is an endless survival shooter:

  1. Start from the main menu.
  2. Move the ship horizontally near the bottom of the screen.
  3. Hold Space to shoot incoming enemies.
  4. Switch weapons with number keys depending on the situation.
  5. Collect power-ups for extra life, shield, or temporary faster fire rate.
  6. Survive increasingly frequent enemy spawns.
  7. Fight a boss at score thresholds.
  8. Lose when all lives are gone.

Controls

Action Input
Move left A / Left Arrow
Move right D / Right Arrow
Shoot Hold Space
Ultimate attack E
Single Shot 1
Double Shot 2
Pierce Shot 3
Splash Shot 4
Start from menu Space / Enter
Pause during gameplay Escape
Resume from pause Space / Enter
Return from pause to menu Escape
Return from game over to menu Space / Enter
Exit from main menu Escape

Note: the old README/GDD mentioned W/S movement, Q ultimate, P pause, and mouse menu navigation. The table above describes the current active code.

Implemented Features

  • Main menu with animated space backdrop.
  • Endless gameplay loop.
  • Horizontal player movement with screen bounds.
  • Auto-fire while Space is held.
  • Manual weapon switching.
  • Ultimate attack with cooldown and large explosion damage.
  • Enemy spawning with increasing difficulty.
  • Four regular enemy types: Slow, Fast, Tank, Zigzag.
  • Boss fight with phases and bullet patterns.
  • Power-ups: Health, Shield, Fire Rate.
  • Score and lives system.
  • HUD with score, lives, weapon info, HP bar, ultimate cooldown, and status messages.
  • Pause overlay that renders gameplay behind a dimmed panel.
  • Game-over screen with final score.
  • Procedural parallax gameplay background.

Design Patterns Used

State Pattern

Used for screen/game mode management:

  • State
  • StateManager
  • MainMenuState
  • GameState
  • PauseState
  • GameOverState

Strategy Pattern

Used for weapon behavior:

  • WeaponStrategy
  • SingleShotStrategy
  • DoubleShotStrategy
  • PierceStrategy
  • SplashStrategy

Factory Pattern

Used for enemy creation:

  • EnemyFactory
  • EnemyFactory.EnemyType

Prototype Pattern Support

Prototype support exists through:

  • EnemyPrototype
  • Enemy.clone()
  • ZigzagEnemy.clone()

Current note: the active factory creates new enemy instances directly. A future improvement would be to store prototype instances in the factory and clone them when spawning enemies.

Singleton Pattern

Used for shared game state:

  • GameManager

It stores score, lives, pause state, game-over state, and dispatches events.

Observer Pattern

Used for game events:

  • GameEvent
  • GameEventListener
  • GameManager.addListener/removeListener/notify

Events include score changes, life changes, game over, pause/resume, enemy kill, boss spawn/defeat, and power-up collection.

Important Gameplay Values

Player

  • Movement speed: 300 px/s.
  • Start lives: 3.
  • Player size: 70 x 80 px.
  • Movement: horizontal only in the current build.
  • Ultimate cooldown: 12 seconds.

Enemies

Type Speed Health Score
Slow 120 2 100
Fast 220 1 50
Tank 60 5 200
Zigzag 100 2 150
Boss Phase-based 220 3000

Weapons

Weapon Delay Damage Notes
Single Shot 0.15s 0.5 Fast single bullet
Double Shot 0.25s 0.5 per bullet Two bullets with wider coverage
Pierce 0.40s 0.5 per enemy Can hit multiple enemies
Splash 0.45s 0.3 in radius Explodes with area damage

Difficulty

  • Enemy spawn interval starts at 2.0 seconds.
  • Spawn interval decreases by 0.05 seconds after each spawn.
  • Minimum spawn interval is 0.5 seconds.
  • First boss appears at 10000 score.
  • Boss repeats every additional 10000 score.

Project Structure

Game/
|-- assets/                         # PNG sprites and runtime asset root
|   |-- sprites/
|   |   |-- player/
|   |   |-- enemies/
|   |   `-- effects/
|   `-- laserBlue01.png
|-- core/
|   `-- src/main/java/game/mygame/
|       |-- background/             # Parallax and menu backgrounds
|       |-- entities/               # Player, enemies, bullets, power-ups, effects
|       |-- factory/                # EnemyFactory
|       |-- observer/               # Game events/listeners
|       |-- state/                  # State pattern implementation
|       |-- ui/                     # Experimental/legacy UI helpers
|       |-- weapon/                 # Weapon Strategy pattern
|       |-- Assets.java
|       |-- GameManager.java
|       |-- GameScreen.java
|       `-- SpaceShooter.java
|-- docs/
|   |-- GDD.md
|   |-- diagrams/
|   `-- UI/UX reports
|-- lwjgl3/
|   `-- src/main/java/game/mygame/lwjgl3/
|       |-- Lwjgl3Launcher.java
|       `-- StartupHelper.java
|-- build.gradle
|-- settings.gradle
|-- gradlew
|-- gradlew.bat
`-- README.md

Documentation

  • Main GDD: docs/GDD.md
  • Diagrams: docs/diagrams/
  • UI/UX audit and reports: docs/

How to Run

IntelliJ IDEA

  1. Open the project root folder.
  2. Import/reload Gradle if needed.
  3. Run game.mygame.lwjgl3.Lwjgl3Launcher from the lwjgl3 module.

Gradle on Windows

.\gradlew.bat :lwjgl3:run

Gradle on macOS/Linux

./gradlew :lwjgl3:run

How to Build

Full Build

.\gradlew.bat build

Desktop Distribution JAR

.\gradlew.bat :lwjgl3:dist

The generated desktop JAR is produced by the lwjgl3 module.

Team

  • Zhalgas - Project Lead / Lead Programmer
  • Nurdaulet - Programmer
  • Abushakhman - Designer / Programmer

Current Limitations

  • No persistent high score saving yet.
  • No audio or music yet.
  • Menus are controlled by keyboard in the active state flow.
  • Health power-up can increase lives above the displayed max lives.
  • Some older/experimental classes remain in the codebase (PlayingState, PauseOverlay, MainMenuUI, GameHUD).
  • Some source comments show encoding corruption and should be cleaned in a later polish pass.

Suggested Next Steps

  1. Add saved high score with libGDX Preferences.
  2. Add shooting, explosion, pickup, boss warning, and game-over sounds.
  3. Decide whether Health should cap at max lives or work as overheal.
  4. Remove or refactor legacy UI/state classes.
  5. Complete Prototype pattern usage inside EnemyFactory.
  6. Add mouse/Scene2D menu buttons if required by the final assignment.
  7. Add final release build and tag when ready to submit.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages