Commit fd149e9b authored by 9731301's avatar 9731301

remove walls bug

parent 14bde8a2
...@@ -3,20 +3,14 @@ ...@@ -3,20 +3,14 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="0b3d586d-9f0f-4ca4-b09d-03a200e1e684" name="Default Changelist" comment=""> <list default="true" id="0b3d586d-9f0f-4ca4-b09d-03a200e1e684" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/Server_Client/registeredName/registeredList" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/Server_Client/registeredName/registeredList" afterDir="false" /> <change beforePath="$PROJECT_DIR$/maps/map1.txt" beforeDir="false" afterPath="$PROJECT_DIR$/maps/map1.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/Main.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/Main.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/maps/map2.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel$3.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel$3.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/BulletState$KeyHandler2.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/BulletState$KeyHandler2.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/BulletState.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/BulletState.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Server_Client/registeredName/registeredList" beforeDir="false" afterPath="$PROJECT_DIR$/src/Server_Client/registeredName/registeredList" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/WallState$WallData.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/WallState$WallData.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/WallState.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/WallState.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/GameState/BulletState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/BulletState.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/UI/GameState/BulletState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/BulletState.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/GameState/RewardState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/RewardState.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/GameState/TankState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/TankState.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/GameState/WallState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/WallState.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/UI/GameState/WallState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/GameState/WallState.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/Game/Rendering.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/Game/Rendering.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/Main.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/MainFrame.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/MainFrame.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/Registration/InitialFrame.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/Registration/InitialFrame.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/Registration/InitialPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/Registration/InitialPanel.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -143,7 +137,7 @@ ...@@ -143,7 +137,7 @@
<workItem from="1596360744874" duration="14702000" /> <workItem from="1596360744874" duration="14702000" />
<workItem from="1596382833689" duration="23785000" /> <workItem from="1596382833689" duration="23785000" />
<workItem from="1596407579858" duration="9000" /> <workItem from="1596407579858" duration="9000" />
<workItem from="1596421183096" duration="8850000" /> <workItem from="1596421183096" duration="16438000" />
</task> </task>
<servers /> <servers />
</component> </component>
...@@ -155,10 +149,10 @@ ...@@ -155,10 +149,10 @@
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="517" y="216" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1536.824@0.0.1536.824" timestamp="1596402386433" /> <state x="517" y="216" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1536.824@0.0.1536.824" timestamp="1596402386433" />
<state x="574" y="122" key="#com.intellij.ide.util.MemberChooser" timestamp="1596425202424"> <state x="574" y="122" key="#com.intellij.ide.util.MemberChooser" timestamp="1596434237281">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="574" y="122" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1596425202424" /> <state x="574" y="122" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1596434237281" />
<state x="566" y="298" width="403" height="237" key="#com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesDialog.classes" timestamp="1596368712645"> <state x="566" y="298" width="403" height="237" key="#com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesDialog.classes" timestamp="1596368712645">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
...@@ -171,22 +165,22 @@ ...@@ -171,22 +165,22 @@
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="593" y="0" key="CommitChangelistDialog2/0.0.1536.824@0.0.1536.824" timestamp="1595639194593" /> <state x="593" y="0" key="CommitChangelistDialog2/0.0.1536.824@0.0.1536.824" timestamp="1595639194593" />
<state width="1493" height="156" key="GridCell.Tab.0.bottom" timestamp="1596430140296"> <state width="1493" height="125" key="GridCell.Tab.0.bottom" timestamp="1596438867507">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="156" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1596430140296" /> <state width="1493" height="125" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1596438867507" />
<state width="1493" height="156" key="GridCell.Tab.0.center" timestamp="1596430140296"> <state width="1493" height="125" key="GridCell.Tab.0.center" timestamp="1596438867506">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="156" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1596430140296" /> <state width="1493" height="125" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1596438867506" />
<state width="1493" height="156" key="GridCell.Tab.0.left" timestamp="1596430140296"> <state width="1493" height="125" key="GridCell.Tab.0.left" timestamp="1596438867506">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="156" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1596430140296" /> <state width="1493" height="125" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1596438867506" />
<state width="1493" height="156" key="GridCell.Tab.0.right" timestamp="1596430140296"> <state width="1493" height="125" key="GridCell.Tab.0.right" timestamp="1596438867507">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state width="1493" height="156" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1596430140296" /> <state width="1493" height="125" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1596438867507" />
<state x="589" y="114" key="RollbackChangesDialog" timestamp="1595702094731"> <state x="589" y="114" key="RollbackChangesDialog" timestamp="1595702094731">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
......
111111111111111111111 1111111111111111111111111
101001001001010100001 1001001001001010100011001
100000000001000110001 1000002000000220001100001
100111000111011100001 1000111100011101110000001
101100000000000100111 1001100200000000010011111
100000111100111100001 1001000111000011110000001
100000010000010000001 1002000001000001000000001
111111111111111111111 1002000001000011000000001
\ No newline at end of file 1111111111111111111111111
\ No newline at end of file
11111
10101
10111
10101
11111
\ No newline at end of file
...@@ -7,14 +7,14 @@ import java.awt.event.KeyEvent; ...@@ -7,14 +7,14 @@ import java.awt.event.KeyEvent;
public class BulletState { public class BulletState {
public int locX, locY, diam , angle; public int locX, locY, diam , angle;
private WallState walls; private WallState wallState;
private boolean keySpace; private boolean keySpace;
private KeyHandler2 keyHandler2 = new KeyHandler2(); private KeyHandler2 keyHandler2 = new KeyHandler2();
private long createTime; private long createTime;
public BulletState(WallState wallState , TankState tankState){ public BulletState(WallState wallState , TankState tankState){
this.walls = wallState ; this.wallState = wallState ;
// Initialize the game state and all elements ... // Initialize the game state and all elements ...
locX = tankState.locX; locX = tankState.locX;
locY = tankState.locY; locY = tankState.locY;
...@@ -26,12 +26,24 @@ public class BulletState { ...@@ -26,12 +26,24 @@ public class BulletState {
} }
public void update(){ public void update(){
if (walls.getWallForBullet(locX , locY) != null) { if (wallState.getWallForBullet(locX , locY) != null) {
if (walls.getWallForBullet(locX, locY).isHorizontal()) { int wallX = wallState.getWallForBullet(locX, locY).getX();
angle = 360 - angle; int wallY = wallState.getWallForBullet(locX , locY).getY();
int width = wallState.w;
int high = wallState.h;
if (wallState.getWallForBullet(locX, locY).isHorizontal()) {
if ((locX > wallX -10 && locX< wallX +10) || (locX < wallX + width +10 && locX> wallX + width -10)) angle = 180 - angle;
else angle = 360 - angle;
if (wallState.getWallForBullet(locX , locY).isDestructible()){
wallState.getWalls().remove(wallState.getWallForBullet(locX , locY));
}
} }
else if (walls.getWallForBullet(locX, locY).isVertical()) { else if (wallState.getWallForBullet(locX, locY).isVertical()) {
angle = 180 - angle; if ((locY > wallY + high -10 && locY< wallY +high +10) || (locY > wallY -10 && locY< wallY +10)) angle = 360 - angle;
else angle = 180 - angle;
if (wallState.getWallForBullet(locX , locY).isDestructible()){
wallState.getWalls().remove(wallState.getWallForBullet(locX , locY));
}
} }
} }
locY += 10*Math.sin(Math.toRadians(angle) ) ; locY += 10*Math.sin(Math.toRadians(angle) ) ;
......
...@@ -15,8 +15,7 @@ public class WallState { ...@@ -15,8 +15,7 @@ public class WallState {
private String source; private String source;
private String[] lines; private String[] lines;
private int numRows, numColumns, w, h; public int numRows, numColumns, w, h;
private final int wallWidth = 5;
private ArrayList<WallData> walls = new ArrayList<>(); private ArrayList<WallData> walls = new ArrayList<>();
private Image wall1 ; private Image wall1 ;
private Image wall2 ; private Image wall2 ;
...@@ -138,8 +137,9 @@ public class WallState { ...@@ -138,8 +137,9 @@ public class WallState {
return false; return false;
} }
public ArrayList<WallData> getWalls() {
return walls;
}
public class WallData { public class WallData {
private int image; private int image;
...@@ -159,7 +159,7 @@ public class WallState { ...@@ -159,7 +159,7 @@ public class WallState {
public boolean isWallForTank (int x,int y){ public boolean isWallForTank (int x,int y){
//BUG //BUG
if (blank) return false; if (blank) return false;
return (x>this.x-w/2 && x<this.x+w && y>this.y-w/2 && y<this.y+h); return (x>this.x-w/2 && x<this.x+w && y>this.y-h/2 && y<this.y+h);
} }
public boolean isWallForBullet (int x,int y){ public boolean isWallForBullet (int x,int y){
...@@ -191,5 +191,14 @@ public class WallState { ...@@ -191,5 +191,14 @@ public class WallState {
public void setDestructible(boolean destructible) { public void setDestructible(boolean destructible) {
this.destructible = destructible; this.destructible = destructible;
} }
public int getX() {
return x;
}
public int getY() {
return y;
}
} }
} }
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