Use an "Object-Based" approach to design and code a Java program (in the Processing PDE) to simulate a "Shooting Gallery" or "Rifle Range" as described below.
SCENE: The "range" (or "shooting gallery") occupies most of the window, running all the way across and from near the bottom to near the top. Leave some room at the top for a title and the SCORE, and leave some room at the bottom for BUTTONs and the author's name.
BUTTONs: Rectangular buttons may be the same size and color, but with different text and different actions as follows:
TARGET: The target moves across the screen, from left to right across the top of the range, after you click the "GO" button. (Target speed may be somewhat random.)
RIFLE: The rifle (a simple rectangle or a "tube") points upward, from the bottom of the range. After each shot, its position is changed to a random X value near the center (perhaps 1/4 to 3/4 across the screen), and it is moved left or right by BUTTONs.
BULLET: When the SHOOT button is clicked, a Bullet object travels straight upward from the rifle until it either hits something or reaches the top or the range; in either case, the bullet disappears. If the bullet hits the target, then points are added to the score depending on which ring it hit. If it hits a varmit, then 2 points are added to the score (and that dangnabbed varmit is gone!)
VARMIT: Two differnt varmits - one bigger than the other, -- run across the range in an animated manner. Each varmit starts at a random height on the left (x=0), with random speed to the right (DX>0) and random direction up or down (DY), then bounces off the top, bottom, and sides of the range. (similar to the cloud in Project 2).
When a varmit is hit, another one (with the same size) starts out (with random X, DX, and DY). Don't fegit to animate them varmints!
TEXT: Add some text, on the screen, such as:
Upload code into your folder, in a file named project4.pde
REMEMBER:
Code
readability
is very important.
|