⭐️ Star this repository! It really motivates me to make better explanations and produce more work!! ⭐️
Space Adventures is an interactive Scratch game where players control a spaceship, avoiding obstacles and collecting points to achieve high scores. Experience thrilling gameplay with intuitive controls and dynamic challenges in this engaging space-themed adventure. This game is hard and consists of 2 phases, will you try to beat it?
- Interactive Gameplay: Players control a spaceship navigating through space using intuitive controls.
- Obstacle Avoidance: Players must avoid various obstacles to survive, adding dynamic challenges to the game.
- Point Collection: Points are collected by destroying obstacles, encouraging skillful play.
- Score Tracking: The game keeps track of the highest score achieved, motivating players to beat their previous records.
- High-Quality Musical Accompaniment: Various musical compositions enhance the gameplay experience, triggered by special events.
- Enemy Spaceship: In the second stage, a special enemy spaceship appears and glides towards the player, adding an additional layer of challenge.
- Super Fire: Every 10 shots, a super fire is launched that can destroy all objects in its path quickly and efficiently.
- Start the Game: Open the Space Adventures project in Scratch.
- Controls: Use the arrow keys to move the spaceship up, down, left, and right.
- Objective: Avoid obstacles and collect points to achieve the highest score.
- End of Game: The game ends when the spaceship crashes into an obstacle. The final score is displayed.
- How to win To win the game 100 points should be obtained.
To play Space Adventures, follow these steps:
- Download Scratch: If you haven't already, download and install Scratch from Scratch's official website.
- Open the Project: Download the Space Adventures project file (
Space Adventures.sb3
) and open it in Scratch.
- Spaceship Movement: Use the arrow keys to move the spaceship up, down, left, and right.
- Obstacle Generation: Obstacles appear randomly with varying sizes and move towards the spaceship, requiring quick reflexes.
- Enemy Spaceship: The enemy spaceship appears in the second stage and steadily moves towards the player's spaceship, forcing evasive maneuvers.
- Super Fire: After every 10 shots, a powerful super fire is activated, passing through and destroying all obstacles rapidly.
- Point System: Points are awarded for each obstacle destroyed and for the distance traveled, encouraging players to stay alive as long as possible.
- Role: Manages the overall game environment, including backgrounds and game states. It also tracks the score and handles game start and end events. The stage controls the transitions between different phases of the game.
- Costumes: The stage has different costumes to represent various backgrounds and game states. These may include:
- Background 1: The initial space background for the first phase of the game.
- Background 2: A different background or a more intense space scene for the second phase when the enemy spaceship appears.
- Role: The player's controllable spaceship. Handles movement using arrow keys and shooting projectiles to destroy obstacles. It is the primary element the player interacts with.
- Role: Represents the obstacles in the game. These rocks appear randomly and move towards the player's spaceship. The player must avoid or destroy these rocks to survive.
- Role: A special enemy that appears in the second phase of the game. It steadily moves towards the player's spaceship, adding an additional layer of challenge that the player must evade.
- Role: Display messages indicating game status, such as win/loss, game over, or instructional text. These sprites are shown at various points during the game.
- Costumes: Each letter sprite has a costume that displays a specific letter or message component. For example:
- Y, O, U, W, O, N: Sprites that spell out "YOU WON" when the winning condition is met.
- G, A, M, E, O, V, E, R: Sprites that spell out "GAME OVER" at the end of the game.
- Role: Represents the bullets fired by the player's spaceship. These bullets are used to destroy obstacles (rocks) and enemy spaceships. The
Button1
sprite handles the shooting mechanics, including bullet movement and collision detection.
- Role: A powerful shot that the player's spaceship can fire every 10 shots. It passes through and destroys all obstacles in its path, providing a temporary advantage.
- Phase 1: The game starts with the player controlling the spaceship and avoiding rocks that appear randomly. The main objective is to survive and collect points by destroying obstacles.
- Phase 2: After a certain score threshold is reached, the game transitions to the second phase. In this phase, the enemy spaceship appears and starts gliding towards the player's spaceship. The player must continue avoiding rocks while also evading the enemy spaceship, increasing the difficulty of the game.
- Event-Driven Programming: The game heavily relies on event-driven programming, using Scratch's broadcasting and event listening features to manage game states and transitions.
- Randomization: Random functions are used to generate obstacles at random positions and with random sizes to ensure the game remains unpredictable and challenging.
- Collision Detection: Scratch's built-in collision detection is used to manage interactions between the spaceship, bullets, and obstacles.
- State Management: Variables are used to keep track of game states such as score, game phase, and bullet count.
- Message Broadcasting: Scratch's message broadcasting system is used to trigger changes between game phases and to handle the appearance of messages like "Game Over" and "You Won".
The spaceship is controlled using the arrow keys. The scripts attached to the spaceship sprite listen for key press events and move the spaceship accordingly:
- Up Arrow: Moves the spaceship up.
- Down Arrow: Moves the spaceship down.
- Left Arrow: Moves the spaceship left.
- Right Arrow: Moves the spaceship right.
The player can shoot bullets by pressing the spacebar. Each time the spacebar is pressed, a bullet sprite (Button1
) is cloned and set to move forward from the spaceship's position:
- Bullet Creation: A new clone of the
Button1
sprite is created. - Bullet Movement: The cloned bullet moves forward until it collides with an obstacle or goes off-screen.
- Collision Handling: When a bullet collides with an obstacle, both the bullet and the obstacle are destroyed, and the player earns points.
Every 10 shots, a super fire is activated which destroys all obstacles in its path:
- Super Fire Activation: A counter keeps track of the number of bullets fired. When it reaches 10, a super fire is triggered.
- Super Fire Behavior: The super fire moves quickly across the screen, destroying any obstacles it touches.
Obstacles (rocks) are generated at random intervals and positions:
- Random Positioning: Obstacles appear at random positions on the right edge of the screen.
- Random Sizes: Obstacles are assigned random sizes to add variety and difficulty.
- Movement: Obstacles move leftward towards the spaceship, increasing the challenge for the player.
In the second phase of the game, an enemy spaceship appears and glides towards the player’s spaceship:
- Appearance Trigger: The enemy spaceship appears once a certain score threshold is reached.
- Movement: The enemy spaceship steadily moves towards the player’s spaceship, forcing the player to evade it while still avoiding obstacles.
This project was inspired by and developed as part of the CS50x course offered by Harvard University. CS50x is Harvard University's introduction to the intellectual enterprises of computer science and the art of programming for majors and non-majors alike, with or without prior programming experience.
Thank you to the CS50x team for providing such a comprehensive and engaging introduction to computer science. |