Add Paddle

master
John 2022-05-30 14:42:42 -04:00
parent 9f30f43361
commit a8edbfbdf6
2 changed files with 20 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="openjdk-18" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="openjdk-18" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

19
src/Paddle.java Normal file
View File

@ -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);
}
}