BSc in Informatics and Computing Engineering
L.EIC014 - Software Design and Testing Laboratory
2024/2025
| Name | Number |
|---|---|
| João Marques | up202307612 |
| Tomás Morais | up202304692 |
| Tomás Silva | up202307796 |
Grade : 16,2
The Space can be a dangerous place. In this 2D space shooter, traverse through the cosmos in a heart pumping adventure where you will dodge asteroids, fight the hardest battles and reclaim space from your enemies
- Controls
- Game Screenshots
- Implemented Features
- Structure and Design Patterns
- Sound Management
- Known Code Smells
- UML Class Diagram
- Testing
Up/Down ArrowKey -> Navigate through options;ENTER-> Select option;- Key
y/Y-> Confirm exit of the game; * - Key
n/N-> Go back to the menu. *
- When the
Exitoption is selected
Up Arrow Key-> Move the ship up;Down Arrow Key-> Move the ship down;- Key
a/A-> Fire projectile; - Key
s/S-> Fire bomb; - Key
q/Q-> Exit the game.
Gif 1 - Menu
Gif 2 - Level 1
Gif 3 - Level 2
Gif 4 - Level 3
Fig. 1 - Game Over Screen
Fig. 2 - Victory Screen
Menu - When the game starts, a menu is displayed. On top the name of the game, Space Ranger, is shown, followed by four available options: Start Game (Level1), Start Level 2, Start Level 3 and Exit. The player can navigate through the menu using the Up and Down arrow keys and select an option by pressing ENTER.
Menu Music - While the player stays in the menu, background music will play.
Start Level Options - If the player selects one of the Start Level options, the game begins at the referenced level. For example, selecting Start Level 2 starts at level 2.
Starting Level Screen - After one of the Start Level options is selected, the screen turns black and displays Starting Level X, for a few seconds before the level begins.
Exit Option - If the player selects Exit, the screen turns black with the message Are you sure you want to exit?. At this point, pressing Y ends the game; pressing N returns to the menu.
Levels - The game has 3 levels, each progressively more difficult. Difficulty increases due to faster asteroids, more enemies, tougher enemy types, and more projectiles.
Ship - The player controls a ship with 3 health points. Each hit reduces health by 1. At 0, it’s GAME OVER.
Moving The Ship - The ship moves up or down with arrow keys.
Firing Projectiles - Pressing A fires a projectile. It’s destroyed if it hits an asteroid, enemy, or enemy projectile.
Firing Bombs - Pressing S fires a bomb. Bombs cannot be destroyed and clear a 2x2 radius. The ship has 5 bombs.
Asteroids - Infinite asteroids appear from the right. Colliding with one = GAME OVER.
Enemies - Enemies come in three types: blue (1 health), yellow (3), red (5). All are destroyed by a single bomb.
Moving Enemies - Enemies move left but stop at a certain x coordinate.
Projectiles Fired by Enemies - Enemies occasionally fire projectiles, destroyed upon collision.
Explosions - Triggered when an enemy dies, the ship is hit, or projectiles collide.
Level Design - Space-themed scenery, bordered by grey frame. Level number at top, controls at bottom.
Health Bar - Top left, shown as green hearts.
Remaining Bombs Displayer - Below health bar, shows bombs left.
Remaining Enemies Displayer - Top right, shows enemies remaining.
Stars - Constantly flash in the background.
Level Music - Unique track per level.
Sound Effects - For projectiles, bombs, and explosions.
Game Progression - Defeating all enemies progresses to the next level.
Victory Screen - After level 3, displays YOU WON!! THANKS FOR PLAYING, with victory audio.
Quitting the Game - Pressing Q exits the game.
Game Over Screen - If the ship is destroyed or game is exited, displays GAME OVER, with audio.
The Application class contains main, which initializes Game and calls start().
We implemented: Singleton, Model-View-Controller (MVC), State, and Game Loop.
Certain classes should only have one instance during runtime. For that, Singleton was used.
Game, Level1, Level2, Level3 - Use getInstance() to check/create a single instance.
- Only one instance exists at runtime;
- Better runtime control.
Originally, one class mixed Model, View, and Controller logic → violating the Single Responsibility Principle. Splitting into Model, View, and Controller solved this.
Contains the data and logic of game elements.
Element- General base for all elements (with coordinates).Position- Definesx/ycoordinates.LiveElement- Elements with health (e.g.,Ship,Enemy).Ship- Subclass ofLiveElement.Enemy- Abstract subclass ofLiveElement. Generalizes:EasierEnemy,AverageEnemy,HarderEnemy.
ShipProjectile,EnemyProjectile,Bomb,Explosion,Boundary,Asteroid,Star- Constructors & drawing logic.Level- Generalizes levels; has abstract methods for specifics.Level1,Level2,Level3- Implement details of each level.
Responsible for visuals.
LevelViewer-drawScreen(),drawLevel(),drawBeforeGameOver().ElementGroupViewer- Interface for drawing grouped elements.AsteroidViewer,ProjectileViewer,BombViewer,ExplosionViewer,EnemyViewer,BoundaryViewer,ShipProjectileViewer,EnemyProjectileViewer,StarViewer- Implement element drawing.ShipViewer- Draws the ship.StatusBar- Interface for status bars.BombBar,ControlsBar,EnemiesBar,HealthBar,LevelBar- Implement status bars.BlackScreenWithText- Interface for black screen + white text.GameCompletionViewer,GameOverViewer- ImplementBlackScreenWithText.MenuViewer- Draws menu + black screens (Loading Level,Exit?).
Handles input and element behavior.
LevelController-processKey(),updateGame(),runLevel().ShipController- Handles ship movement.EnemyController- Handles enemy movement.ProjectileController- General base for projectile logic.AgainstEnemiesProjectileController- ForShipProjectileController,BombController. Moves right.AgainstShipProjectileController- ForEnemyProjectileController,AsteroidController. Moves left.ShipProjectileController,EnemyProjectileController,BombController,AsteroidController- Collision + movement logic.MenuController-startLevel(),handleExit(),handleInputInExit().
- More organized code;
- Easier to modify;
- Closer to Single Responsibility Principle.
Menu, Game Over, Victory, and Level classes can all be treated as states of Game.
GameStates- Enum of 6 states +NULL.GameState- Interface for state logic + transitions.MenuState- Menu logic.Level1State,Level2State- Handle transitions between levels or toGame Over.Level3State- Transitions toGame CompletionorGame Over.GameOverState,GameCompletionState- End screens.Game- Maintains running state viastart(), updates withsetState().
- State transitions separated from rest of code;
- Clearer and explicit game flow.
We wanted frame rate control (60 FPS) for smoothness.
LevelController-runLevel()loop callsupdateGame(),drawLevel(),processKey().Game-start()initializes resources, runs while state ≠NULL.
- Smooth frame rate;
- Continuous updates;
- More immersive experience.
SoundPlayer - playSound(path), stopSound().
Audio files (.wav) stored in resources/.
All Error Prone issues fixed, no major smells remain.
Note: despite some failed tests, we kept them to increase coverage.







