Skip to content
Snippets Groups Projects
Commit f90eedcf authored by bosskkev's avatar bosskkev
Browse files

Ajout des raquettes

parent ed2ec792
No related branches found
No related tags found
No related merge requests found
Pipeline #22753 failed
......@@ -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
......
......@@ -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
......
src/main/resources/pong/raquette1.png

674 B

src/main/resources/pong/raquette2.png

603 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment