From 870424d1c5ea9632d51e3cb65b90ca4bde7cda10 Mon Sep 17 00:00:00 2001 From: Lenz Date: Sat, 6 Jun 2020 14:51:42 +0200 Subject: [PATCH] =?UTF-8?q?score=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/Game.class | Bin 6065 -> 6675 bytes bin/Ghost.class | Bin 1479 -> 1509 bytes src/Game.java | 42 +++++++++++++++++++++++++++++------------- src/Ghost.java | 36 ++++++++++-------------------------- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/bin/Game.class b/bin/Game.class index e0fcf3d861c2301f2e3a97d31f4117e414654640..49c709fb0f8c2d5698243d2284a73e2bba99136b 100644 GIT binary patch literal 6675 zcma)B3wTu3wf^_aIdkSr4v>UI1dQ@F8IWMWC=CP%7zhN35+i|HGf5_4Fquh{;SqYJ z*A`#ZJ`lYM+A0*AVr>;l1`x#uf)5nAwOGYgZLbx@_ge`U?!V5N$xI~NHs3dAul=vR z9((Pz*WTykxf2iX1~5?-8*nLTGXu>*1DZnmlEAV+ep4Xam_M&}Nw6-epf|LVtB_SL zycPLv%R}VOE)}$h?3O?{*mMfJLQt|jElq*;V5@?+yuzjgYg`;@i?$J4R6bKkV(#WZ z3ze164YaW5s;6N!n?O^bEn3O8tuE3^Csdh&&!)=*wY`|NQ7Z7&2Wc%DY8KP(h87x2 zqu=$B1>sE~Q;V)#&q;iB$47Ib(FO#1dPdr^ESa)wQ@V8Cl&8mDD1 zgUC*|kOs@Z#hlfmMGFng6m z%PcI%3Qn9cn-gp=54A;uVc9O{q>K+PW9afz*m2>N7Jh*LaIDCVVx%|`@t_c^Ec{S- zY4jkmr3Am$!jJG{*}uVPRj4gg+e9%fcVS+Y7uQi$MWF7yxq+|@y}`nbvi4pMtqet* zxUCBD6AL$syhZS`U|VQqfEtAHQwu-C&lS!jV@9wcu(T;Uy(!WboYxX;wKuewi95H( z!mU`#S#vBy%PB`?S0rQVEO9s*2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>+;rPna-?Xk5U^1Mvy_wNyg8gi9;Yye zH~C-S0B;bH2}qcGixKHipcsK7{V9b0p&~5`A%Mv^(+@JB=g;O+!+j)5`6DbG zAel>z_7Rg&`GuGaHw02dNRlAI4BOALlN2x?bU7A~#oKs?9PEsDiPn@99a>WIzlZn7 z{6BI)ov22s^fMMx@lI-{mw$LJHJo^g4}!4s%?y^F;X?w-L1vDC(fwD~zkvT*56}QA$ez-?7pLYFJlF8^lPZRD(Lb5VL&tW2JwwPAc71o4QPrjXh-M zC%)f9s&t>?^^V$ImM6FOFs)7|gOi6mVS3?E?N!!({8DXMC!%}+S=)T6wk*4rnJyn{ za;D%}T;S6NuJb0Ad9y2g3>9Aa4P3-3u40Xu8g6r%`<%nZCi Map.points[j][i].xPos - 5 && player.getPos('y', 0) < Map.points[j][i].yPos + 5 && player.getPos('y', 0) > Map.points[j][i].yPos - 5) { + Map.points[j][i].setBounds(0, 0, 0, 0); + + Map.points[j][i] = null; + + score++; + scoreLabel.setText(Integer.toString(score)); } } } } - player.calcDir(0); // Berechnen wo Pac-Man als nächstes hin soll for (int i = 0; i < ghosts.length; i++) { @@ -272,8 +288,8 @@ public class Game { player.lives--; System.out.println(player.lives); delay(200); - for(int j = 0; j < ghosts.length; j++) { - ghosts[j].setPos('x', Map.ghost_posX[j]); + for (int j = 0; j < ghosts.length; j++) { + ghosts[j].setPos('x', Map.ghost_posX[j]); ghosts[j].setPos('y', Map.ghost_posY[j]); player.setPos('x', Map.pac_posX); player.setPos('y', Map.pac_posY); @@ -282,12 +298,12 @@ public class Game { player.right = false; player.left = false; } - + } } fps = 1000000000 / dt; - // System.out.println("fps: " + fps + " | delaytimer: " + delaytimer); + // System.out.println("fps: " + fps); delay(delaytimer); // Ein delay zum Ende der Hauptschleife diff --git a/src/Ghost.java b/src/Ghost.java index cc3a483..d87b090 100644 --- a/src/Ghost.java +++ b/src/Ghost.java @@ -4,16 +4,14 @@ public class Ghost extends Picture { // Die private static final long serialVersionUID = -5352006665147359473L; - public int xPos; - public int yPos; - - + public float xPos; + public float yPos; + public boolean up; public boolean down; public boolean left; public boolean right; - //private float speed = 0.00000007f; private int HCost; public Ghost(int index) { @@ -32,8 +30,6 @@ public class Ghost extends Picture { // Die } - - public void setPos(char coordinate, int newPos) { if (coordinate == 'x') { xPos = newPos; @@ -41,43 +37,31 @@ public class Ghost extends Picture { // Die yPos = newPos; } } - - - /* - public void setDirection(String dir) { - direction = dir; - } - public String getDirection() { - return direction; - } - */ + public int getHCost(Player player, int mod_x, int mod_y) { - - HCost = (int) Math.sqrt(Math.pow((((xPos - 10 )/20) + mod_x) - (( player.getPos('x', 0) - 10)/20), 2) + Math.pow((((yPos - 10 )/20) + mod_y) - ((player.getPos('y', 0) - 10)/20), 2)); - + + HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) + + Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2)); + return HCost; } - + public int getPos(char coordinate, long dt) { // Hier kommt die zuvor erwähnte delta time ins Spiel if (coordinate == 'x') { // Auslesen der 'x' - Koordinate: if (left && dt != 0) { - // xPos -= speed * dt; xPos -= 1; } else if (right && dt != 0) { - // xPos += speed * dt; xPos += 1; } return (int) xPos; } else if (coordinate == 'y') { // Auslesen der 'y' - Koordinate: if (down && dt != 0) { - // yPos += speed * dt; yPos += 1; } else if (up && dt != 0) { - // yPos -= speed * dt; yPos -= 1; } - return (int) yPos; //(int) + return (int) yPos; // (int) } else { return -1; }