diff --git a/src/Dashboard.java b/src/Dashboard.java index f588f5c..c0cecf8 100644 --- a/src/Dashboard.java +++ b/src/Dashboard.java @@ -1,3 +1,4 @@ +import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -29,12 +30,17 @@ public class Dashboard extends GameView this.button = new JButton(); // ajout background - setBackground(car.getColor()); + frame.setBackground(car.getColor()); init(fn); - - frame.add(label); - frame.add(button); + + // mettre un layout (text au centre et bouton en bas) + // this.setLayout(new BorderLayout()); + // this.add(label, BorderLayout.CENTER); + // this.add(button, BorderLayout.SOUTH); + this.setLayout(new BorderLayout()); + this.add(label, BorderLayout.CENTER); + this.add(button, BorderLayout.SOUTH); } // fonction uniquement pour l'affichage dynamique diff --git a/src/GameView.java b/src/GameView.java index c17f414..edeee1c 100644 --- a/src/GameView.java +++ b/src/GameView.java @@ -25,6 +25,7 @@ public abstract class GameView extends JComponent frame.setContentPane(this); // visibilité de la fenetre frame.setVisible(true); + register(); } protected GameView register() @@ -43,6 +44,7 @@ public abstract class GameView extends JComponent { for (GameView o : vobs) { + System.out.println(o.getClass()); o.run(); } } diff --git a/src/Main.java b/src/Main.java index 535a849..d29e1f5 100644 --- a/src/Main.java +++ b/src/Main.java @@ -3,13 +3,40 @@ import java.awt.Color; public class Main { public static void main(String[] args) throws InterruptedException { - Game game = new Game.Builder() - .defaultMap() - .setPlayers(3) - .build(); + // Game game = new Game.Builder() + // .defaultMap() + // .setPlayers(3) + // .build(); + + Integer[][] map = new Integer[][] + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -1, -1, 5, 0 }, + { 0, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 0, 0, -1, 0, 0, -1, 0 }, + { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0 }, + { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0 }, + { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -1, -1, 2, 0, 0, -1, 0 }, + { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, + { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, + { 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -3, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }; - game.run(); + Map m = Map.fromInts(map); + + // game.run(); - // Dashboard d = new Dashboard(new Car(10, new State()), "Voiture 1", Color.BLUE, 500, 500, 10, 10); + // Dashboard d = new Dashboard(new Car(10, new State()), "Voiture 1", null, Color.BLUE, 500, 500, 10, 10); + Car[] cars = new Car[] { new Car(m.getPathSize(), new State(), Color.PINK)}; + System.out.println(cars[0].getLoop()); + Track t = new Track(m, cars, null, 1080, 512, 0, 0); + Dashboard d = new Dashboard(cars[0], null, () -> true, 300, 300, 0, 0); + while(cars[0].getRound() < 1) + { + + cars[0].run(); + GameView.update(); + Thread.sleep(500); + } } } \ No newline at end of file diff --git a/src/Track.java b/src/Track.java index e1770c0..a33f1c5 100644 --- a/src/Track.java +++ b/src/Track.java @@ -14,7 +14,6 @@ public class Track extends GameView { super(title, width, height, x, y); this.map = map; this.cars = cars; - register(); } @Override