Skip to content

luke-Uni/Space.Game

Repository files navigation

Raumschiff-Game

Overview

Raumschiff-Game is a simple 2D spaceship game where the player controls a rocket to avoid or destroy UFOs while dodging obstacles and maintaining a high score. The game offers two difficulty modes: easy and hard. The goal is to survive as long as possible without hitting walls or UFOs.

Features

  • Difficulty Levels: Choose between easy or hard modes.
  • Collision Detection: Detect collisions with UFOs or walls.
  • Score System: Keep track of your score based on how long you survive and how many UFOs you destroy.
  • Rocket Health: The rocket has 3 hearts (lives), and collisions will reduce health.
  • Auto-recovery: After a collision, the rocket is temporarily invulnerable.

How to Play

  1. Start the Game:

    • Open the game in a browser.
    • Select the difficulty level: "Easy" or "Hard" by clicking the respective button.
  2. Controls:

    • Arrow Up (↑): Move the rocket up.
    • Arrow Down (↓): Move the rocket down.
    • Space: Shoot (not implemented in this version).
  3. Objective:

    • Avoid colliding with UFOs and the walls.
    • Your rocket has 3 lives. When all lives are lost, the game will end, and your score will be displayed.
    • The score increases as you survive longer and destroy UFOs.
  4. Game Over:

    • After losing all lives, the game will display the final score and automatically reload after 5 seconds.

Setup

Requirements

  • A modern web browser that supports HTML5 and JavaScript.
  • Download the assets required for the game (images for the rocket, UFO, hearts, etc.).

Installation

  1. Clone the repository:

    git clone <repository-url>
  2. Ensure the necessary assets (e.g., rakete.png, ufo.png, herz.png, hintergrund.png, Explosion.png, schild.png) are in the same directory as the HTML and JavaScript files.

  3. Open the index.html file in your preferred browser to start playing the game.

File Structure

  • index.html: The main HTML file that sets up the structure of the game, including buttons, canvas, and score display.
  • space_game.js: The JavaScript file that contains the game logic, including movement, collision detection, score tracking, and rendering.
  • Assets (Images): Make sure the following images are included in the same directory:
    • rakete.png: The rocket image.
    • herz.png: The heart (life) icon.
    • ufo.png: The UFO enemy.
    • hintergrund.png: The game background image.
    • Explosion.png: The explosion effect.
    • schild.png: The shield icon for recovery after collision.

Game Logic

  • Movement: The rocket moves up and down based on the arrow keys. UFOs move from right to left.
  • Collisions: Collisions with UFOs or walls will damage the rocket. After 3 collisions, the game ends.
  • Score: The score increases with time and for each UFO destroyed.
  • Recovery Mode: After a collision, the rocket enters a brief recovery period where it is invincible and changes appearance.

About

This Project is based on a YouTube video. (Link: https://www.youtube.com/watch?v=eWLDAAMsD-c&t=4448s) The project is significantly extended. The physics were updated, multiple modes are implemented and a score is added.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors