Question: Using 2 codes from the image, please create a Java game called Pong for one - a rectangular paddle moves back and forth via mouse
Using 2 codes from the image, please create a Java game called Pong for one - a rectangular paddle moves back and forth via mouse drag along the bottom of the pane; the bottom of the paddle should be about 1/2 the diameter of the ball off the bottom. If the ball connects with the paddle, then it bounces at a 90 degrees angle back into the pane space. If the ball misses the paddle, then the score is decremented by 1. The game ends when 20 points are lost.
Nice things:
a) A label that displays the score (you can start at 20 and go to zero if you want...)
b) For every 10 paddle connections in a row, the ball moves faster
c) For every 10 paddle connections in a row, the ball changes color
d) For every (2?) paddle misses in a row, the paddle grows in length
There is MATH involved in figuring out the connection between the paddle and the ball. You probably want to pay a lot of attention to how moveBall() works.


BallPane Notepad File Edit Format View Help package chapter15; import javafx.animation.KeyFrame; import javafx.animation. Timeline; import javafx.beans .property. DoubleProperty; import javafx. scene.layout.Pane; import javafx.scene. paint Colo import javafx.scene shape. Circle import javafx.util.Duratio public class BallPane extends Pane public final double radius 20 private double x radius, y radius private double dx 1, dy 1; private Circle circle new Circle (x, y, radius); private Timeline animation; public BallPane f circle. SetFill (Color GREEN); Set ball colo getChildren ().add (circle Place a ball into this pane Create an animation for moving the ball animation new Timeline new Key Frame (Duration .millis (50), e moveBall animation. setCycleCount (Timeline. INDEFINITE animation play Start animation public void play animation play public void pause animation pause BallPane Notepad File Edit Format View Help package chapter15; import javafx.animation.KeyFrame; import javafx.animation. Timeline; import javafx.beans .property. DoubleProperty; import javafx. scene.layout.Pane; import javafx.scene. paint Colo import javafx.scene shape. Circle import javafx.util.Duratio public class BallPane extends Pane public final double radius 20 private double x radius, y radius private double dx 1, dy 1; private Circle circle new Circle (x, y, radius); private Timeline animation; public BallPane f circle. SetFill (Color GREEN); Set ball colo getChildren ().add (circle Place a ball into this pane Create an animation for moving the ball animation new Timeline new Key Frame (Duration .millis (50), e moveBall animation. setCycleCount (Timeline. INDEFINITE animation play Start animation public void play animation play public void pause animation pause
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
