From a8edbfbdf6f56ec8a9d3a5ba2ccda7e0a077c5db Mon Sep 17 00:00:00 2001 From: John Date: Mon, 30 May 2022 14:42:42 -0400 Subject: [PATCH] Add Paddle --- .idea/misc.xml | 2 +- src/Paddle.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/Paddle.java diff --git a/.idea/misc.xml b/.idea/misc.xml index d15472f..1ce6e7f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/Paddle.java b/src/Paddle.java new file mode 100644 index 0000000..42c3c90 --- /dev/null +++ b/src/Paddle.java @@ -0,0 +1,19 @@ +/* Eric Li, ICS4U, Completed 5/29/2022 + +Ball class defines behaviours for the pong ball; it also adds no new functions and instead inherits its main functions from GenericObject */ + +import java.awt.*; + +public class Paddle extends GenericObject { + public int INITIAL_SPEED = 6; + public static final int BALL_DIAMETER = 15; + public Paddle(int x, int y, int xDirection) { + super(x, y, BALL_DIAMETER, BALL_DIAMETER); + // set initial speed + super.setXDirection(INITIAL_SPEED * xDirection); + } + public void draw(Graphics g) { + g.setColor(Color.YELLOW); + g.fillRect(x, y, BALL_DIAMETER, BALL_DIAMETER); + } +} \ No newline at end of file