diff --git a/assets/Map.txt b/assets/Map.txt index 6fdea19..b81a620 100644 --- a/assets/Map.txt +++ b/assets/Map.txt @@ -12,6 +12,6 @@ # # # # # # ####### ## ## # # # # # # ############# ###### ## # # # # # ############# ## ## -# # # # ##################### ## ## -# # #################### ## -############################123#### \ No newline at end of file +# # # # ################### # ## ## +# # ################### ## +#######################123######### \ No newline at end of file diff --git a/bin/Game.class b/bin/Game.class index 9625daa..286fd14 100644 Binary files a/bin/Game.class and b/bin/Game.class differ diff --git a/bin/Player.class b/bin/Player.class index b5fa448..6ac2e33 100644 Binary files a/bin/Player.class and b/bin/Player.class differ diff --git a/src/Game.java b/src/Game.java index d579ff6..e233d42 100644 --- a/src/Game.java +++ b/src/Game.java @@ -19,6 +19,10 @@ public class Game { // Delta time: siehe https://en.wikipedia.org/wiki/Delta_timing private long dt; private long lastT; + + private int delaytimer = 9; + + private long fps = 60; private int windowSizeX = 800; // Größe des Frame in x-Richtung private int windowSizeY = 800; // Größe des Frame in y-Richtung @@ -144,7 +148,12 @@ public class Game { map.mapping(); } } - delay(10); // Ein delay von 10s zum Ende der Hauptschleife + fps = 1000000000 / dt; + + // System.out.println("fps: " + fps + " | delaytimer: " + delaytimer); + + delay(delaytimer); // Ein delay zum Ende der Hauptschleife + } } diff --git a/src/Player.java b/src/Player.java index 12b7618..070c567 100644 --- a/src/Player.java +++ b/src/Player.java @@ -15,7 +15,7 @@ public class Player extends Picture implements KeyListener { // extends Picture public int lives = 3; - private float speed = 0.00000014f; // Diee Geschwindigkeit von Pac-man. In alle Richtungen gleich. Muss so klein + private float speed = 0.0000001f; // Diee Geschwindigkeit von Pac-man. In alle Richtungen gleich. Muss so klein // sein wegen delta time public long timer; // Variable die speichert zu welchem Zeitpunkt eine Änderung der Richtung @@ -34,8 +34,8 @@ public class Player extends Picture implements KeyListener { // extends Picture public boolean down; public boolean pressed_down; - private boolean hui; // Boolean zur Abfrage, ob gerade ein Brick im Weg ist, um den aktuellen - // Richtungsbefehl durchzuführen. + public boolean hui; // Boolean zur Abfrage, ob gerade ein Brick im Weg ist, um den aktuellen + // Richtungsbefehl durchzuführen. public Player() { // Erstellen des Konstruktors @@ -216,15 +216,19 @@ public class Player extends Picture implements KeyListener { // extends Picture if (coordinate == 'x') { // Auslesen der 'x' - Koordinate: if (left && dt != 0) { xPos -= speed * dt; + System.out.println(speed * dt); } else if (right && dt != 0) { xPos += speed * dt; + System.out.println(speed * dt); } return (int) xPos; } else if (coordinate == 'y') { // Auslesen der 'y' - Koordinate: if (down && dt != 0) { yPos += speed * dt; + System.out.println(speed * dt); } else if (up && dt != 0) { yPos -= speed * dt; + System.out.println(speed * dt); } return (int) yPos; } else {