Assignment Requirements
Apply to the task description. Please use java language and processing 2.1.1 to program.
Please include:
– Pixels & Variables
– Conditionals
– Loops
– Functions
– Arrays & Strings
Part A: Fish (10%)
Assignment two drew a swimming fish that is supposed to escape through a barrier at the right of the display window. A partial code for drawing the fish body has been supplied in drawFish function. Update it to create a fish with a spiky tail. The body of the fish should be blue with a green eye in the middle. The width and height of the fish are fishWidth and fishHeight respectively (provided in ass3.zip). Each time the fish moves forward, it should do so by fishWidth pixels and upon pressing an UP or DOWN key, it should move up or down respectively, by fishHeight pixels. In the beginning, the fish appears such that its right-most point is at x = 0, and its top-most point (fishY) is at a multiple of fishHeight and in the range [0, height[ (including 0, and excluding height)
The tail should have 5 spikes, drawn using a loop (no marks if a purposeful loop is not used), each having one end at the middle left of the blue rectangle that represents the fish, and the other ends of the 5 spikes should be evenly spread from the top of the fish body to the bottom of the fish body. The width of the tail should be the same as the width of the fish body. Apart from these specifications, the tail should resemble the example on
Part B: Barriers (35%)
As your main task, you are required to create multiple barriers, using a loop, in the path (no marks if a purposeful loop is not used). These barriers must satisfy following criteria There are N_BARRIERS barriers (declaration of N_BARRIERS provided in ass3.zip)!
Size of each barrier should be same: barrierWidth ( = fishWidth), barrierHeight ( = fishHeight) (provided in ass3.zip)!
All barriers are displayed as red borderless rectangles.!
The basic attributes of the barriers (x position, y position) should be stored in arrays (no marks if arrays not used to draw the barriers), you can add any additional attributes you need.!
The top-left corner of barrier corresponding to index i is at (x[i], y[i]) such that x[i] is a multiple of barrierWidth and y[i] is a multiple of barrierHeight such that all barriers are completely within display window.!
Part C: Reset barriers and fish each time fish crosses the screen (15%)!
The entire barrier set is replaced by a new barrier set each time the entire fish (including the spiky tail) crosses the screen (fish completely disappears to the right of the display window), and also the fish restarts from the left side of the window. You are free to choose the initial y coordinate of the fish as long as its a multiple of fishWidth.!
Part D: Collision and scoring (14%)!
When the fish collides with a barrier, it should start again from the left and the score should be decreased by 3. Each time the fish crosses the display window without colliding with a barrier, the score should be increased by 3. The score should be displayed towards the top left corner of the display window.!
Part E: Hang on! Some barriers are actually food (10%)!
Roughly thirty percent of the barriers should be “food” for the fish, and displayed in green. When a fish collides with a green barrier, the score should be increased by 1, and the green barrier hit should disappear.
Part F: Open ended (16%)!
You can add a non-trivial functionality to the program in this part. Three examples of substantial functionality have been implemented and demonstrated in the assignment video, namely,
1. Pausing and un-pausing!
Order Now