Commit df5b7f99 authored by nargessalehi98's avatar nargessalehi98

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/GameState.java
parents 1f112716 2215d357
011010001010111011100100010100010 111111111111111111111
001111111000110100001011011001011 100010000011120000001
101101001010111000111110101010110 100010000010000001001
101001110100001111001001011000111 100011100000000002001
011101001110111111100000101001011 100010000000000002001
010011011101001101111010010001000 100220000010000002001
010001000001001010001000101001110 100010000010000001001
010111011111000011001100101100010 100010000011110000001
010001001001100001100011111001011 100000000110000000001
010111111000010001001100100011100 100000000100001120001
111001011100110001000101100001011 100000000100001000001
111111100100100001100001001100100 100000000100000000001
101100110110000001111001011110010 111111111111111111111
110110101011010011111111100011111 \ No newline at end of file
110101010000101101111001101011010
011111111010011010011010111100110
000110110001010010111110011110110
101111111110110011101111010000011
\ No newline at end of file
100001101100101100010010001000000 100001
100101010101100001011010000000001 100011
001001110000001100101010110101111 101010
101000110111111010000001101010011 101000
100010111111011110011001011111010 111111
111101111100111110100101100000001 \ No newline at end of file
001010001110000011011000100000101
010101010001110111100110000011011
011010010110111111001101100110111
101010010101111101000000011010000
010000100000100011001001101100100
000111000001100101110001011011100
101011011111010111011100100001100
000001001101100110111111111111000
111100001110101011010001111110000
101010101011010011111101011010011
101010100111111100101101010111010
011111001101111000011000101100011
\ No newline at end of file
010110001001000010010100011101111 1111111
110111110100001001000110100010010 1010011
010010010001010000111011010111000 1111001
010100000111011010110001110011111 1000001
010000110110001101110100000011011 1000001
100000101011111010001011010010100 1010001
101000011111001101011011001100000 1111101
101010110111010111100100010101001
000101010111111111011110010010101
000111111001111011110101100111010
011011010110000100110110101000101
000000001111111011000011111011000
001001111010001110111010001001101
110011001001110110100001110011001
111101011000110000010101001100011
101100111101110111101010100101100
001001000101010101111101010101100
000000001011011011011000000100100
\ No newline at end of file
1111111
1000001
1010001
1010001
1111111
...@@ -32,15 +32,12 @@ public class GameState { ...@@ -32,15 +32,12 @@ 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;
boolean PermissionDown = true;
boolean PermissionUp = true;
public GameState(int num) { public GameState(int num) {
locX = 100; locX = 100;
locY = 100; locY = 100;
//changed from 42 to 25 diam = 42;
diam = 25;
rotateAmount = 0; rotateAmount = 0;
gameOver = false; gameOver = false;
// //
...@@ -68,7 +65,7 @@ public class GameState { ...@@ -68,7 +65,7 @@ public class GameState {
public Rectangle getBounds(int locX, int locY) { public Rectangle getBounds(int locX, int locY) {
return new Rectangle(locX, locY, 28, 28); return new Rectangle(locX, locY, 25, 25);
} }
/** /**
...@@ -81,69 +78,44 @@ public class GameState { ...@@ -81,69 +78,44 @@ public class GameState {
locX = mouseX - diam / 2; locX = mouseX - diam / 2;
} }
if (keyUP) { if (keyUP) {
PermissionUp = true; boolean Permission = true;
for (Wall wall : Controller.walls) { for (Wall wall : Controller.walls) {
if (wall.intersects(getBounds(locX + 5, locY + 5))) {
if (wall.getWidth() == 5 && wall.getHeight() == 50 ) { System.out.println("4");
if ((getBounds(locX, locY).intersects(new Rectangle((int) wall.getX(), (int) wall.getY(), 5, 50)))) { Permission = false;
PermissionUp = false;
break; break;
} }
} }
//&& rotateAmount != 90 && rotateAmount != -90 && rotateAmount != 270 && rotateAmount != -270 if (Permission)
if (wall.getWidth() == 50 && wall.getHeight() == 5) {
if ((getBounds(locX, locY).intersects(new Rectangle((int) wall.getX(), (int) wall.getY(), 50, 5)))) {
PermissionUp = false;
break;
}
}
// && rotateAmount != 180 && rotateAmount != -180 && rotateAmount != 0
}
if (PermissionUp)
move(+5); move(+5);
} }
if (keyDOWN) { if (keyDOWN) {
PermissionDown = true; boolean Permission = true;
for (Wall wall : Controller.walls) { for (Wall wall : Controller.walls) {
if (wall.getWidth() == 5 && (wall.getHeight() == 50 || wall.getHeight() == 5)) { if (wall.intersects(getBounds(locX + 5, locY + 5))) {
if ((getBounds(locX, locY).intersects(new Rectangle((int) wall.getX(), (int) wall.getY(), 5, 50)))) { System.out.println("5");
PermissionDown = false; Permission = false;
break; break;
} }
} }
//&& rotateAmount != 90 && rotateAmount != -90 && rotateAmount != 270 && rotateAmount != -270 if (Permission)
if ((wall.getWidth() == 50 || wall.getWidth() == 5) && wall.getHeight() == 5) {
if ((getBounds(locX, locY).intersects(new Rectangle((int) wall.getX(), (int) wall.getY(), 50, 5)))) {
PermissionDown = false;
break;
}
}
//&& rotateAmount != 180 && rotateAmount != -180 && rotateAmount != 0
}
if (PermissionDown)
move(-5); move(-5);
} }
if (keyLEFT) { if (keyLEFT)
rotateAmount -= 15; rotateAmount -= 15;
}
if (keyRIGHT) { if (keyRIGHT)
rotateAmount += 15; rotateAmount += 15;
}
locX = Math.max(locX, 40); locX = Math.max(locX, 40);
//Formula for tank movement limit
locX = Math.min(locX, 20 + (((Controller.col - 1) / 2) * 50) + (((Controller.col - 1) / 2) + 1) * 5 - 25); locX = Math.min(locX, 20 + (((Controller.col - 1) / 2) * 50) + (((Controller.col - 1) / 2) + 1) * 5 - 25);
locY = Math.max(locY, 70); locY = Math.max(locY, 70);
//Formula for tank movement limit locY = Math.min(locY, 50 + ((Controller.row - 1) / 2) * 50 + (((Controller.row - 1) / 2) + 1)*5 -25);
locY = Math.min(locY, 50 + ((Controller.row - 1) / 2) * 50 + (((Controller.row - 1) / 2) + 1) * 5 - 25);
} }
public void move(int px) { public void move(int px) {
......
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