Difference between revisions of "Asteroids"
From WLCS
(→Asteroids) |
|||
(18 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
* The player's ship will be affected by momentum and physics | * The player's ship will be affected by momentum and physics | ||
* The player will be able to fire at asteroids and break them apart | * The player will be able to fire at asteroids and break them apart | ||
− | |||
* Points will be given to the player for destroying asteroids | * Points will be given to the player for destroying asteroids | ||
== Requirements == | == Requirements == | ||
=== Ship Movement === | === Ship Movement === | ||
− | * | + | * Pressing the Right-key turns the ship to the right |
− | * Pressing the | + | * Pressing the Left-key turns the ship to the left |
+ | * Pressing the Up-key will accelerate the ship and go forwards | ||
*# Create a '''speed''' variable and set it to 0 | *# Create a '''speed''' variable and set it to 0 | ||
− | *# If the | + | *# If the Up-key is pressed, then increase '''speed''' by a little bit (e.g. 0.5) |
*# Else, if speed is greater than 0, then decrease '''speed''' by a little bit (e.g. -0.5) | *# Else, if speed is greater than 0, then decrease '''speed''' by a little bit (e.g. -0.5) | ||
*# Move the ship '''speed''' steps | *# Move the ship '''speed''' steps | ||
− | * Pressing the | + | * Pressing the Down-key will decelerate the ship and go backwards |
− | ** Follow the same steps as the | + | ** Follow the same steps as the Up-key, but reverse/negate everything |
+ | |||
+ | === Screen-wrapping === | ||
+ | * If the ship goes beyond the top edge, it should appear at the bottom edge of the screen, and vice versa | ||
+ | * If the ship goes beyond the right edge, it should appear at the left edge of the screen, and vice versa | ||
=== Firing Projectiles === | === Firing Projectiles === | ||
− | * Pressing | + | * Pressing space bar down will fire a projectile (use clones) |
** The projectile should disappear when it hits the edge of the screen | ** The projectile should disappear when it hits the edge of the screen | ||
− | ** If the | + | ** If the space bar is held down, a projectiles (clones) should be fired every 0.5 second |
+ | * A laser/firing sound should be played when a projectile is fired | ||
=== Asteroids === | === Asteroids === | ||
− | # Make an asteroid appear at a random edge of the screen | + | * Multiple asteroids should appear on the screen from different sides and move. There are two basic ways of doing it: |
− | ## Pick a random number between 1-4 (each number corresponds to a side) | + | * Method 1: |
− | ## | + | *# Create 4 different large asteroid sprites |
− | ## Give it a random direction ( | + | *# Each asteroid sprite randomizes its starting location from a particular side, so that each side has an asteroid |
− | # Have | + | *# Have the asteroid move across the screen |
+ | *# The asteroid should wrap around to the other side of the screen | ||
+ | * Method 2: | ||
+ | *# Make an asteroid appear at a random edge of the screen | ||
+ | *## Pick a random number between 1-4 (each number corresponds to a side) | ||
+ | *## Use if-statements to check for each number 1 through 4, | ||
+ | *### Tell the asteroid to appear at a random place along that side (will be different for each side) | ||
+ | *### Give it a random direction (depends on the side the asteroid is located) | ||
+ | *# Have the asteroid move across the screen | ||
+ | *# The asteroid should wrap around to the other side of the screen | ||
+ | |||
+ | === Asteroid Collisions === | ||
+ | * If asteroids collide with the ship: | ||
+ | ** Play a sound for the collision | ||
+ | ** Show an explosion or animation | ||
+ | ** Display a "Game over" message | ||
+ | * If projectiles hit the asteroids: | ||
+ | ** The asteroid should break apart | ||
+ | **# One way of doing this involves 2 different sprites for asteroids: a large asteroid and smaller asteroid. | ||
+ | **# When the larger asteroid is hit, you can hide it or delete its clone | ||
+ | **# Then you can create several clones of the smaller asteroids at the location where the larger asteroid was hit | ||
+ | **# Be sure to randomize the directions of the smaller asteroids | ||
+ | ** Play a sound for the explosion | ||
+ | ** Points given to the player | ||
+ | |||
+ | === Aesthetics === | ||
+ | * Use a basic star field for the background | ||
+ | * Find simple background music to use -- something appropriate for the theme of the game | ||
+ | |||
+ | == Advanced Requirements == | ||
+ | * Health bar for the ship | ||
+ | * Other flying objects on the screen give different point values | ||
+ | * Use a cloud variable for the high score |
Latest revision as of 12:29, 28 January 2014
Contents
Objectives
- You will create a game that mimics gameplay of Asteroids
- The player will be able to move around using the keyboard
- The player's ship will be affected by momentum and physics
- The player will be able to fire at asteroids and break them apart
- Points will be given to the player for destroying asteroids
Requirements
Ship Movement
- Pressing the Right-key turns the ship to the right
- Pressing the Left-key turns the ship to the left
- Pressing the Up-key will accelerate the ship and go forwards
- Create a speed variable and set it to 0
- If the Up-key is pressed, then increase speed by a little bit (e.g. 0.5)
- Else, if speed is greater than 0, then decrease speed by a little bit (e.g. -0.5)
- Move the ship speed steps
- Pressing the Down-key will decelerate the ship and go backwards
- Follow the same steps as the Up-key, but reverse/negate everything
Screen-wrapping
- If the ship goes beyond the top edge, it should appear at the bottom edge of the screen, and vice versa
- If the ship goes beyond the right edge, it should appear at the left edge of the screen, and vice versa
Firing Projectiles
- Pressing space bar down will fire a projectile (use clones)
- The projectile should disappear when it hits the edge of the screen
- If the space bar is held down, a projectiles (clones) should be fired every 0.5 second
- A laser/firing sound should be played when a projectile is fired
Asteroids
- Multiple asteroids should appear on the screen from different sides and move. There are two basic ways of doing it:
- Method 1:
- Create 4 different large asteroid sprites
- Each asteroid sprite randomizes its starting location from a particular side, so that each side has an asteroid
- Have the asteroid move across the screen
- The asteroid should wrap around to the other side of the screen
- Method 2:
- Make an asteroid appear at a random edge of the screen
- Pick a random number between 1-4 (each number corresponds to a side)
- Use if-statements to check for each number 1 through 4,
- Tell the asteroid to appear at a random place along that side (will be different for each side)
- Give it a random direction (depends on the side the asteroid is located)
- Have the asteroid move across the screen
- The asteroid should wrap around to the other side of the screen
- Make an asteroid appear at a random edge of the screen
Asteroid Collisions
- If asteroids collide with the ship:
- Play a sound for the collision
- Show an explosion or animation
- Display a "Game over" message
- If projectiles hit the asteroids:
- The asteroid should break apart
- One way of doing this involves 2 different sprites for asteroids: a large asteroid and smaller asteroid.
- When the larger asteroid is hit, you can hide it or delete its clone
- Then you can create several clones of the smaller asteroids at the location where the larger asteroid was hit
- Be sure to randomize the directions of the smaller asteroids
- Play a sound for the explosion
- Points given to the player
- The asteroid should break apart
Aesthetics
- Use a basic star field for the background
- Find simple background music to use -- something appropriate for the theme of the game
Advanced Requirements
- Health bar for the ship
- Other flying objects on the screen give different point values
- Use a cloud variable for the high score