Commit 94e27df8 authored by nargessalehi98's avatar nargessalehi98

Add back and for movement.

parent df5b7f99
...@@ -32,6 +32,7 @@ public class GameState { ...@@ -32,6 +32,7 @@ public class GameState {
private boolean one = false; private boolean one = false;
private boolean two = false; private boolean two = false;
private boolean three = false; private boolean three = false;
private int step=0;
public GameState(int num) { public GameState(int num) {
...@@ -78,30 +79,42 @@ public class GameState { ...@@ -78,30 +79,42 @@ public class GameState {
locX = mouseX - diam / 2; locX = mouseX - diam / 2;
} }
if(step>2)
step=0;
if (keyUP) { if (keyUP) {
boolean Permission = true; boolean PermissionDown = true;
for (Wall wall : Controller.walls) { for (Wall wall : Controller.walls) {
if (wall.intersects(getBounds(locX + 5, locY + 5))) { if (wall.intersects(getBounds(locX + 5, locY + 5))) {
System.out.println("4"); System.out.println("4");
Permission = false; PermissionDown = false;
break; break;
} }
} }
if (Permission) if (PermissionDown)
move(+5);
if(!PermissionDown && step<2){
move(+5); move(+5);
step++;
}
} }
if (keyDOWN) { if (keyDOWN) {
boolean Permission = true; boolean PermissionUp = true;
for (Wall wall : Controller.walls) { for (Wall wall : Controller.walls) {
if (wall.intersects(getBounds(locX + 5, locY + 5))) { if (wall.intersects(getBounds(locX + 5, locY + 5))) {
System.out.println("5"); System.out.println("5");
Permission = false; PermissionUp = false;
break; break;
} }
} }
if (Permission) if (PermissionUp)
move(-5); move(-5);
if(!PermissionUp && step<2) {
move(-5);
step++;
System.out.println(step);
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment