Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and develop a Cannon Game App with Canvas and Animation Timer: The app challenges you to destroy nine targets before a ten second time

Design and develop a Cannon Game App with Canvas and Animation Timer:


 

The app challenges you to destroy nine targets before a ten second time limit expires. All of the required sounds are located in the 'exerciseResources' folder in the textbook Java How to Program, 11/e, Early Objects Version, but you also can use free sounds from many websites or create your own.

 

The game consists of a cannon, a cannonball, nine targets and a blocker that defends the targets—the blocker cannot be destroyed. The blocker and each target move vertically at different speeds, reversing direction when they hit the Canvas's top or bottom. You aim and fire the cannon by clicking the mouse—the cannon's barrel then rotates to aim at the click point and fires the cannonball in a straight line in that direction.

 

You win by destroying all nine targets before time expires—if the timer reaches zero, you lose. When you destroy a target, the time remaining increases by a three-second time bonus. When you hit the blocker, the time remaining decreases by a three-second time penalty. When the game ends, the app displays an Alert dialog (package javafx.scene.control) indicating whether you won or lost, and showing the number of shots fired and the elapsed time. 

 

When you fire the cannon, the game plays a firing sound (cannon_fire.wav) and a cannonball begins moving from the cannon's barrel toward the blocker and targets. When a cannonball hits a target, a glass-breaking sound (target_hit.wav) plays and that target disappears. When the cannonball hits the blocker, a hit sound (blocker_hit.wav) plays and the cannonball bounces back toward the cannon. (NB: you can use you're own sounds if you want)

 

Use a Canvas to implement the game's graphics. This app should perform its animations manually by updating the game elements using 'AnimationTimers' as shown of the textbook 'Java™ How to Program Early Objects ELEVENTH EDITION' . Consider defining classes that represent the various game elements—each class can define its own 'AnimationTimer' to specify how to move a game element of that type.

 

For simplicity, perform collision detection, based on the cannonball's bounding box—that is, the square area in which the cannonball is drawn— rather than the cannoball's circular area. If the cannonball's bounding box intersects with the blocker's or a target's bounds, then a collision occurred. 

 

Explain why the rectangular bounding is less precise in this exercise . Please provide comments/explanations?


Time remaining in game- Cannonball in flight toward the blocker Cannon blocker Time remaining: 8.1 seconds Remaining targets

Step by Step Solution

3.50 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

To implement the Cannon Game App we can create the following classes CannonGame This is the main class that will contain the game loop handle user input and manage the game elements Cannon This class ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Project Management The Managerial Process

Authors: Eric W Larson, Clifford F. Gray

8th Edition

1260570436, 978-1260570434

More Books

Students also viewed these Programming questions

Question

=+7.2 Large-Sample Confidence Intervals for a Population Mean

Answered: 1 week ago