Add Paddle
parent
9f30f43361
commit
a8edbfbdf6
|
@ -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>
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue