Commit fd149e9b authored by 9731301's avatar 9731301

remove walls bug

parent 14bde8a2
......@@ -3,20 +3,14 @@
<component name="ChangeListManager">
<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$/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$/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$/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/Registration/InitialPanel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel.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$/maps/map1.txt" beforeDir="false" afterPath="$PROJECT_DIR$/maps/map1.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/maps/map2.txt" beforeDir="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/GameState/BulletState.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/BulletState.class" 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/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/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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -143,7 +137,7 @@
<workItem from="1596360744874" duration="14702000" />
<workItem from="1596382833689" duration="23785000" />
<workItem from="1596407579858" duration="9000" />
<workItem from="1596421183096" duration="8850000" />
<workItem from="1596421183096" duration="16438000" />
</task>
<servers />
</component>
......@@ -155,10 +149,10 @@
<screen x="0" y="0" width="1536" height="824" />
</state>
<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" />
</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">
<screen x="0" y="0" width="1536" height="824" />
</state>
......@@ -171,22 +165,22 @@
<screen x="0" y="0" width="1536" height="824" />
</state>
<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" />
</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="156" key="GridCell.Tab.0.center" 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="125" key="GridCell.Tab.0.center" timestamp="1596438867506">
<screen x="0" y="0" width="1536" height="824" />
</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="156" key="GridCell.Tab.0.left" 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="125" key="GridCell.Tab.0.left" timestamp="1596438867506">
<screen x="0" y="0" width="1536" height="824" />
</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="156" key="GridCell.Tab.0.right" 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="125" key="GridCell.Tab.0.right" timestamp="1596438867507">
<screen x="0" y="0" width="1536" height="824" />
</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">
<screen x="0" y="0" width="1536" height="824" />
</state>
......
111111111111111111111
101001001001010100001
100000000001000110001
100111000111011100001
101100000000000100111
100000111100111100001
100000010000010000001
111111111111111111111
\ No newline at end of file
1111111111111111111111111
1001001001001010100011001
1000002000000220001100001
1000111100011101110000001
1001100200000000010011111
1001000111000011110000001
1002000001000001000000001
1002000001000011000000001
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;
public class BulletState {
public int locX, locY, diam , angle;
private WallState walls;
private WallState wallState;
private boolean keySpace;
private KeyHandler2 keyHandler2 = new KeyHandler2();
private long createTime;
public BulletState(WallState wallState , TankState tankState){
this.walls = wallState ;
this.wallState = wallState ;
// Initialize the game state and all elements ...
locX = tankState.locX;
locY = tankState.locY;
......@@ -26,12 +26,24 @@ public class BulletState {
}
public void update(){
if (walls.getWallForBullet(locX , locY) != null) {
if (walls.getWallForBullet(locX, locY).isHorizontal()) {
angle = 360 - angle;
if (wallState.getWallForBullet(locX , locY) != null) {
int wallX = wallState.getWallForBullet(locX, locY).getX();
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 (wallState.getWallForBullet(locX, locY).isVertical()) {
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));
}
else if (walls.getWallForBullet(locX, locY).isVertical()) {
angle = 180 - angle;
}
}
locY += 10*Math.sin(Math.toRadians(angle) ) ;
......
......@@ -15,8 +15,7 @@ public class WallState {
private String source;
private String[] lines;
private int numRows, numColumns, w, h;
private final int wallWidth = 5;
public int numRows, numColumns, w, h;
private ArrayList<WallData> walls = new ArrayList<>();
private Image wall1 ;
private Image wall2 ;
......@@ -138,8 +137,9 @@ public class WallState {
return false;
}
public ArrayList<WallData> getWalls() {
return walls;
}
public class WallData {
private int image;
......@@ -159,7 +159,7 @@ public class WallState {
public boolean isWallForTank (int x,int y){
//BUG
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){
......@@ -191,5 +191,14 @@ public class WallState {
public void setDestructible(boolean 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