Commit 4da00adb authored by 9831111's avatar 9831111 🙂

Check vertical wall enter.

parent 893fe053
011010001010111011100100010100010
001111111000110100001011011001011
101101001010111000111110101010110
101001110100001111001001011000111
011101001110111111100000101001011
010011011101001101111010010001000
010001000001001010001000101001110
010111011111000011001100101100010
010001001001100001100011111001011
010111111000010001001100100011100
111001011100110001000101100001011
111111100100100001100001001100100
101100110110000001111001011110010
110110101011010011111111100011111
110101010000101101111001101011010
011111111010011010011010111100110
000110110001010010111110011110110
101111111110110011101111010000011
\ No newline at end of file
111111111111111111111
100010000011120000001
100010000010000001001
100011100000000002001
100010000000000002001
100220000010000002001
100010000010000001001
100010000011110000001
100000000110000000001
100000000100001120001
100000000100001000001
100000000100000000001
111111111111111111111
\ No newline at end of file
100001101100101100010010001000000
100101010101100001011010000000001
001001110000001100101010110101111
101000110111111010000001101010011
100010111111011110011001011111010
111101111100111110100101100000001
001010001110000011011000100000101
010101010001110111100110000011011
011010010110111111001101100110111
101010010101111101000000011010000
010000100000100011001001101100100
000111000001100101110001011011100
101011011111010111011100100001100
000001001101100110111111111111000
111100001110101011010001111110000
101010101011010011111101011010011
101010100111111100101101010111010
011111001101111000011000101100011
\ No newline at end of file
100001
100011
101010
101000
111111
\ No newline at end of file
010110001001000010010100011101111
110111110100001001000110100010010
010010010001010000111011010111000
010100000111011010110001110011111
010000110110001101110100000011011
100000101011111010001011010010100
101000011111001101011011001100000
101010110111010111100100010101001
000101010111111111011110010010101
000111111001111011110101100111010
011011010110000100110110101000101
000000001111111011000011111011000
001001111010001110111010001001101
110011001001110110100001110011001
111101011000110000010101001100011
101100111101110111101010100101100
001001000101010101111101010101100
000000001011011011011000000100100
\ No newline at end of file
1111111
1010011
1111001
1000001
1000001
1010001
1111101
1111111
1000001
1010001
1010001
1111111
......@@ -32,12 +32,15 @@ public class GameState {
private boolean one = false;
private boolean two = false;
private boolean three = false;
boolean PermissionDown = true;
boolean PermissionUp = true;
public GameState(int num) {
locX = 100;
locY = 100;
diam = 42;
//changed from 42 to 25
diam = 25;
rotateAmount = 0;
gameOver = false;
//
......@@ -64,48 +67,82 @@ public class GameState {
}
public Rectangle getBounds(int locX,int locY){
return new Rectangle( locX, locY, 25, 25);
public Rectangle getBounds(int locX, int locY) {
return new Rectangle(locX, locY, 28, 28);
}
/**
* The method which updates the game state.
*/
public void update() throws AWTException {
public void update() {
if (rotateAmount >= 360 || rotateAmount <= -360) rotateAmount = 0;
if (mousePress) {
locY = mouseY - diam / 2;
locX = mouseX - diam / 2;
}
if (keyUP) {
// boolean Permission=true;
// for (Wall wall : Controller.walls) {
// if(wall.intersects(getBounds(locX+5,locY+5))){
// System.out.println("4");
// Permission = false;
// break;
// }
// }
// if (Permission)
PermissionUp = true;
for (Wall wall : Controller.walls) {
//if (Math.abs(locX - wall.getX()) <= 5 && Math.abs(locY - wall.getY()) <= 5) {
if (wall.getWidth() == 5 && wall.getHeight() == 50 && rotateAmount != 90 && rotateAmount != -90 && rotateAmount != 270 && rotateAmount != -270) {
if ((getBounds(locX, locY).intersects(new Rectangle((int) wall.getX(), (int) wall.getY(), 5, 50)))) {
System.out.println("2");
//if (PermissionDown)
PermissionUp = false;
break;
}
}
}
if (PermissionUp)
move(+5);
}
if (keyDOWN) {
boolean Permission=true;
PermissionDown = true;
for (Wall wall : Controller.walls) {
if (wall.getWidth() == 5 && wall.getHeight() == 50) {
if ((getBounds(locX, locY).intersects(new Rectangle((int) wall.getX(), (int) wall.getY(), 5, 50)))) {
System.out.println("3");
if (PermissionUp)
PermissionDown = false;
break;
}
}
if (wall.getWidth() == 50 && wall.getHeight() == 5) {
if ((getBounds(locX, locY - 2).intersects(new Rectangle((int) wall.getX(), (int) wall.getY(), 50, 5)))) {
System.out.println("4");
if (PermissionUp)
PermissionDown = false;
break;
}
}
}
if (PermissionDown)
move(-5);
}
if (keyLEFT)
if (keyLEFT) {
rotateAmount -= 15;
}
if (keyRIGHT)
if (keyRIGHT) {
rotateAmount += 15;
}
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.max(locX, 42);
locX = Math.min(locX, GameFrame.GAME_WIDTH - diam - 42);
locY = Math.max(locY, 70);
locY = Math.min(locY, ((Controller.row-1)/2)*50+60);
//Formula for tank movement limit
locY = Math.min(locY, 50 + ((Controller.row - 1) / 2) * 50 + (((Controller.row - 1) / 2) + 1) * 5 - 25);
}
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