CSCI 136 |
In this assignment, you will be creating an animated Starfield Display. Your job is to write the support class and the main program for the display. You will work with dynamic arrays in Java as well as practice some of the things you learned last semester. |
public class Star ----------------------------------------------------------------------------------------- Star() // create a star at screen position 0.5, 0.5 and random x and y // velocities between -0.005 and +0.005 void update() // update the x, y position of the star by its velocity void draw() // draw the star as a white circle with radius 0.002 boolean gone() // return true if the star has gone off the screen (x or y // position less than 0 or greater than 1
Do I need to follow the prescribed API? Yes. You may not add public methods to the API; however, you may add private methods (which are only accessible in the class in which they are declared) if you need them. The public methods you write should return the data type shown in the API, and take input parameters (if any) as specified.
Can I use Java's built in ArrayList class? Absolutely! Please do! That's kind of the point of this assignment. There will be assignments coming soon where I will require you to write your own data structures rather than using the Java library though.
Grade Item | Points Possible | Points Earned |
---|---|---|
Program Compiles | 1 | |
Program Runs | 1 | |
javadoc comments on all classes and methods | 4 | |
Implemented Star() constructor correctly | 3 | |
Implemented Star update) correctly | 3 | |
Implemented Star draw() correctly | 3 | |
Implemented Star gone() correctly | 3 | |
Implemented ArrayList additions and removals correctly | 6 | Implemented Starfield animation loop correctly | 4 |
Draws correctly | 2 | |
Total | 30 |
Extra credit idea 1.
Create a black hole somewhere on the display where, if a star enters that area, it gets sucked in and disappears.
Extra credit idea 2.
Same as above, but make it so that as a star gets closer to a black hole, its velocity changes so that it is drawn toward it.
Extra credit idea 3. Instead of random velocities, make it so that individual stars tend to have similar velocities to their neighbors in the array. This should create "swarm behavior" in the stars.
For the extra credit ideas, you may have to change the API to the Star class. Be sure that the one you submit as your lab assignment follows the API. The extra credit work does not have to.
Page last updated: December 27, 2018