Giter VIP home page Giter VIP logo

asteroids's Introduction

Asteroids (Part 1)

In this assignment we will start to replicate the old video game Asteroids. You will write a program that has a space ship that can be controlled with the keyboard. You will need to write a Spaceship class. Your Spaceship class will extend the Floater class, an abstract class that represents all things that float in space.

An abstract class is an "incomplete" class. It has abstract methods--incomplete methods that have no body. When your class extends an abstract class, you typically write the methods that are needed to "complete" the class. Note: To complete this assignment you will be writing two classes Spaceship and Star. Do not modify the Floater class.

Suggested steps to complete this assignment

  1. Fork this repository.
  2. Open the program by opening AsteroidsGame.pde in Processing.
  3. Uncomment the extends floater on Line 1 of Spaceship.pde
  4. Complete the 10 abstract set and get functions that the Spaceship class inherits from Floater
  5. Write the Spaceship constructor. Make sure you initialize all 9 of the inherited protected member variables. You may find slides #1 - 58 on the Asteroids PowerPoint and the Spaceship design worksheet helpful. You may also find this sample Spaceship program helpful in understanding how the protected Floater variables affect the Spaceship's movement.
  6. At the top of AsteroidsGame.pde, declare a variable of type Spaceship
  7. Initialize the Spaceship as a new instance of the class
  8. In draw() in AsteroidsGame.pde call the Spaceship's show() function
  9. When you are happy with appearance of the Spaceship, add a public void keyPressed() function in AsteroidsGame.pde
  10. Write code in keyPressed that allows you to control the spaceship with the keyboard. You must include the ability to turn left, turn right, accelerate, and enter "hyperspace." (There is no requirement for any fancy visual effects, hyperspace just needs to stop the ship, and give it a new random position and direction.)
  11. Add code to the draw() in AsteroidsGame.pde to move() the Spaceship
  12. Finish the Stars class in Stars.pde
  13. Finally, add code to AsteroidsGame.pde that declares and initializes an instance of the Stars class to create a random number of stars in random positions
  14. Note that for full credit, you MUST include instructions on how to operate your Spaceship in the index.html file
  15. OPTIONAL: If you have extra time and are looking for a challenge, you might try to add an animation of "rockets" that appear from the back of the ship when you accelerate, simliar to the this sample Spaceship program. The best way to do this is to override show() by copying the show() function from Floater into your Spaceship class. Then add an if statement in your Spaceship show() function right after endShape(CLOSE);. If your rockets are firing, draw additional shapes just behind your Spaceship. You can sketch out the shapes on graph paper with the ship centered at (0,0) and pointing right. The show() function will rotate and translate the rocket shapes to the correct position on the screen.

These steps are only a suggestion. Your Asteroids game doesn't have to work or act like any other. Have fun and be creative.

Some important things to keep in mind

  1. Abstract classes are "unfinished"
  2. Abstract classes are one way that programmers can collaborate and divide up the work of a large program
  3. You're collaborating! Some of the work for the Spaceship class has already been done in the Floater class. Don't change it! Your job is to extend the Floater class to "build on top of it" to make a Spaceship class.
  4. To create the Spaceship class you need to write a constructor and finish the "unfinished" abstract functions in Floater.`
  5. When you are sketching out your ship on the Spaceship design worksheet make sure the ship is centered at (0,0) and pointing to the right
  6. Don't declare any duplicate variables in your Spaceship class. You are inheriting all the variables you need from Floater
  7. Make sure your constructor initializes all 9 of the protected variables it inherits from Floater

asteroids's People

Contributors

simart avatar

Watchers

Andrew Smith avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.