diff --git a/src/main/java/pong/PongApp.java b/src/main/java/pong/PongApp.java index 4e2ed8e00d4598d647cc775969b9ba4a15756480..7b57252b3b9b8e706ebe3476610bf34b9203aef7 100644 --- a/src/main/java/pong/PongApp.java +++ b/src/main/java/pong/PongApp.java @@ -17,14 +17,16 @@ public class PongApp { } public static void main(String[] args) throws IOException { - // TODO: Add rackets - PongBall pongBall = new PongBall("Ball", "src/main/resources/sprint2_demo/asteroid.png", new Coordinates2D(10, 10), 64, 64); - PongBall pongBall2 = new PongBall("Ball2", "src/main/resources/sprint2_demo/asteroid.png", new Coordinates2D(40, 40), 64, 64); - PongBall pongBall3 = new PongBall("Ball3", "src/main/resources/sprint2_demo/asteroid.png", new Coordinates2D(70, 70), 64, 64); + PongRacket leftRacket = new PongRacket("Left racket", "src/main/resources/pong/raquette1.png", new Coordinates2D(5, 100), 30, 120); + components.add(leftRacket); + + PongRacket rightRacket = new PongRacket("Right racket", "src/main/resources/pong/raquette2.png", new Coordinates2D(815, 100), 30, 120); + components.add(rightRacket); + + // TODO: Add rackets + PongBall pongBall = new PongBall("Ball", "src/main/resources/sprint2_demo/asteroid.png", new Coordinates2D(100, 10), 64, 64); components.add(pongBall); - components.add(pongBall2); - components.add(pongBall3); Grid grid = new Grid(); // Will create a new grid and a new kernel grid.init("Pong", 850, 500); // Will start the kernel and set the keys listeners diff --git a/src/main/java/pong/PongRacket.java b/src/main/java/pong/PongRacket.java index 84a1a32f6f4b04321b92a79d184108808c8e68cf..af33d904b262938e10c4ef7e57b5d6faa4dadd04 100644 --- a/src/main/java/pong/PongRacket.java +++ b/src/main/java/pong/PongRacket.java @@ -6,7 +6,18 @@ import java.awt.*; public class PongRacket implements PongObject { + public String name; + private final int width; + private final int height; private Coordinates2D position; + private final Image image; + PongRacket(String name, String imagePath, Coordinates2D position, int width, int height) { + this.name = name; + this.width = width; + this.height = height; + this.image = Toolkit.getDefaultToolkit().getImage(imagePath); + this.position = position; + } @Override public Coordinates2D getPosition() { @@ -15,17 +26,17 @@ public class PongRacket implements PongObject { @Override public Image getImage() { - return null; + return this.image; } @Override public int getWidth() { - return 0; + return width; } @Override public int getHeight() { - return 0; + return height; } @Override diff --git a/src/main/resources/pong/raquette1.png b/src/main/resources/pong/raquette1.png new file mode 100644 index 0000000000000000000000000000000000000000..cbbffa0a904a783f3d869393fc5d8c1cad2f2982 Binary files /dev/null and b/src/main/resources/pong/raquette1.png differ diff --git a/src/main/resources/pong/raquette2.png b/src/main/resources/pong/raquette2.png new file mode 100644 index 0000000000000000000000000000000000000000..5365975a11328ac9cd1c68a6284510fc006f132c Binary files /dev/null and b/src/main/resources/pong/raquette2.png differ