Commit c5f1d789 authored by 9731301's avatar 9731301

complete some settings

parent 81e7c71b
......@@ -8,29 +8,29 @@
<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$/maps/map1.txt" beforeDir="false" afterPath="$PROJECT_DIR$/maps/map1.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/Server_Client/NetWorkGame/Client1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/Server_Client/NetWorkGame/Client1.class" 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/GameState/RewardState.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/RewardState.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/TankState.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/GameState/TankState.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$/out/production/JTankTrouble/UI/LogIn/MainPanel$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$1.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$2.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$2.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$3.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$3.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$4.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$4.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$5.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel$5.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/MainPanel.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/NetWorkGame/NWGLoop.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/NetWorkGame/NWGLoop.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/Setting.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/LogIn/Setting.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel$1.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel$2.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JTankTrouble/UI/Registration/InitialPanel$2.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/Client.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Server_Client/Client.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Server_Client/NetWorkGame/Client1.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Server_Client/NetWorkGame/Client1.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Server_Client/Server.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Server_Client/Server.java" 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$/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/MainPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/MainPanel.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/NetWorkGame/NWGLoop.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/NetWorkGame/NWGLoop.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/NetWorkGame/NWGRendering.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/NetWorkGame/NWGRendering.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/Setting.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/Setting.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/Registration/InitialPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/Registration/InitialPanel.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UI/LogIn/SettingPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/UI/LogIn/SettingPanel.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -174,7 +174,8 @@
<workItem from="1596736621086" duration="2472000" />
<workItem from="1596753755315" duration="9970000" />
<workItem from="1596805407066" duration="11801000" />
<workItem from="1596824371588" duration="683000" />
<workItem from="1596824371588" duration="1310000" />
<workItem from="1596884826456" duration="10887000" />
</task>
<servers />
</component>
......@@ -182,14 +183,14 @@
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state x="517" y="216" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1596402386433">
<state x="517" y="216" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1596890904278">
<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="1596755270557">
<state x="517" y="216" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1536.824@0.0.1536.824" timestamp="1596890904278" />
<state x="574" y="122" key="#com.intellij.ide.util.MemberChooser" timestamp="1596888173096">
<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="1596755270557" />
<state x="574" y="122" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1596888173096" />
<state x="499" y="197" key="#com.intellij.ide.util.TreeClassChooserDialog" timestamp="1596591250036">
<screen x="0" y="0" width="1536" height="824" />
</state>
......@@ -210,22 +211,22 @@
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="549" y="153" key="FileChooserDialogImpl/0.0.1536.824@0.0.1536.824" timestamp="1596567968810" />
<state width="1493" height="266" key="GridCell.Tab.0.bottom" timestamp="1596825061812">
<state width="1493" height="119" key="GridCell.Tab.0.bottom" timestamp="1596896371835">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="266" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1596825061812" />
<state width="1493" height="266" key="GridCell.Tab.0.center" timestamp="1596825061812">
<state width="1493" height="119" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1596896371835" />
<state width="1493" height="119" key="GridCell.Tab.0.center" timestamp="1596896371835">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="266" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1596825061812" />
<state width="1493" height="266" key="GridCell.Tab.0.left" timestamp="1596825061812">
<state width="1493" height="119" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1596896371835" />
<state width="1493" height="119" key="GridCell.Tab.0.left" timestamp="1596896371835">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="266" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1596825061812" />
<state width="1493" height="266" key="GridCell.Tab.0.right" timestamp="1596825061812">
<state width="1493" height="119" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1596896371835" />
<state width="1493" height="119" key="GridCell.Tab.0.right" timestamp="1596896371835">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="266" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1596825061812" />
<state width="1493" height="119" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1596896371835" />
<state x="589" y="114" key="RollbackChangesDialog" timestamp="1595702094731">
<screen x="0" y="0" width="1536" height="824" />
</state>
......@@ -234,10 +235,10 @@
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="249" y="0" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1596591266758" />
<state x="107" y="201" key="com.intellij.ide.util.TipDialog" timestamp="1596824371717">
<state x="107" y="201" key="com.intellij.ide.util.TipDialog" timestamp="1596885982849">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="107" y="201" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1596824371717" />
<state x="107" y="201" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1596885982849" />
<state x="578" y="330" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1596406077996">
<screen x="0" y="0" width="1536" height="824" />
</state>
......@@ -263,4 +264,20 @@
</state>
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1595684580506" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/Server_Client/NetWorkGame/Client1.java</url>
<line>80</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/Server_Client/NetWorkGame/Client1.java</url>
<line>51</line>
<option name="timeStamp" value="4" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
\ No newline at end of file
1111111111111111111111111
1001001001001010100011001
1000002000000220001100001
1000111100011101110000001
1001100200000000010011111
1001000111000011110000001
1002000001000001000000001
1002000001000011000000001
1111111111111111111111111
\ No newline at end of file
11111111111111111111
10000100010000002001
10000100011100002001
10000100010000000001
11100000020000000001
10000000000000000001
11111111111111111111
\ No newline at end of file
1111111111111111111111111
1001001001001010100011001
1000002000000220001100001
1000111100011101110000001
1001100200000000010011111
1001000111000011110000001
1002000001000001000000001
1002000001000011000000001
1111111111111111111111111
\ No newline at end of file
......@@ -30,7 +30,6 @@ public class Client1 {
this.host = address;
this.port = port;
numOfEnemies = 0;
wallState = new WallState(GameFrame.GAME_WIDTH , GameFrame.GAME_HEIGHT);
}
public void run0() throws IOException {
......@@ -42,26 +41,22 @@ public class Client1 {
public void run1wall() throws IOException {
out.write(InitialPanel.userName.getText().getBytes());
byte[] buffer = new byte[2048];
int read = in.read(buffer);
wallMap = new String(buffer,0,read);
setWallState();
}
public void runToUpdateTank(TankState tankState) throws IOException {
try {
boolean running = true;
// do {
String clientText = "";
clientText = myTankComponents();
running = !clientText.equalsIgnoreCase("over");
out.write(clientText.getBytes());
byte[] buffer1 = new byte[2048];
int read1 = in.read(buffer1);
serverAns = new String(buffer1, 0, read1);
System.out.println("- From Server : " + serverAns);
// }while(running);
} catch (IOException ex) {
ex.printStackTrace();
}
......@@ -82,10 +77,10 @@ public class Client1 {
return numOfEnemies;
}
public ArrayList<EnemyTank> createEnemyTanks(){
public ArrayList<EnemyTank> createEnemyTanks() throws IOException {
ArrayList<EnemyTank> enemyTanks = new ArrayList<>();
for (int i = 0 ; i < getNumOfEnemies() ; i ++){
EnemyTank enemyTank = new EnemyTank(getWallState());
EnemyTank enemyTank = new EnemyTank(wallState);
enemyTanks.add(enemyTank);
}
if (enemyTanks == null)
......@@ -126,8 +121,12 @@ public class Client1 {
return tankComponent+bulletComponent;
}
public WallState getWallState() {
private void setWallState() throws IOException {
wallState = new WallState(GameFrame.GAME_WIDTH , GameFrame.GAME_HEIGHT);
wallState.setSource(wallMap);
}
public WallState getWallState() {
return wallState;
}
}
......@@ -61,7 +61,7 @@ public class RewardState {
public int chooseRandomReward(){
Random random = new Random();
int x = random.nextInt(5);
int x = random.nextInt(3);
return x;
}
......@@ -77,11 +77,11 @@ public class RewardState {
case 1:
reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\heart.png"));break;
case 2:
reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\bullet.png"));break;
reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\laser.png"));break;
case 3:
reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\bullets.png"));break;
case 4:
reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\laser.png"));break;
reward = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\bullet.png"));break;
}
rewardImage = reward.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH);
return rewardImage;
......@@ -93,9 +93,9 @@ public class RewardState {
switch (numOfReward) {
case 0:shield(tankState);break;
case 1:extraLife(tankState);break;
case 2:extraBulletDamage(tankState);break;
case 2:laser(tankState);break;
case 3:extraBulletDamage2(tankState);break;
case 4:laser(tankState);break;
case 4:extraBulletDamage(tankState);break;
}
}
......
package UI.GameState;
import UI.LogIn.MainPanel;
import javax.imageio.ImageIO;
import java.awt.*;
import java.io.File;
......@@ -8,6 +10,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Random;
public class WallState {
......@@ -27,7 +30,8 @@ public class WallState {
frameY = GAME_HEIGHT;
try {
source = new String(Files.readAllBytes(Paths.get(source)), StandardCharsets.UTF_8);
if (MainPanel.singlePlay)
setSource(findMapPath());
wall1 = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\wall1.png"));
wall2 = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\wall2.png"));
blank = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\blank.png"));
......@@ -137,8 +141,19 @@ public class WallState {
return false;
}
public void setSource(String source) {
this.source = source;
public String findMapPath(){
Random random = new Random();
int x = random.nextInt(2);
System.out.println(x);
switch (x){
case 0:return "C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\maps\\map1.txt";
case 1:return "C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\maps\\map3.txt";
}
return null;
}
public void setSource(String mapPath) throws IOException {
source = new String(Files.readAllBytes(Paths.get(mapPath)), StandardCharsets.UTF_8);
}
public ArrayList<WallData> getWalls() {
......
package UI.LogIn.Game;
import UI.GameState.*;
import UI.LogIn.MainPanel;
import UI.LogIn.Setting;
import UI.LogIn.SettingPanel;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.AffineTransform;
......@@ -22,7 +25,7 @@ public class Rendering {
int lastRender = -1;
private ArrayList<Float> fpsHistory;
private ArrayList<RewardState> rewards = new ArrayList<>();
private Setting setting = new Setting();
private boolean flag = true;
public Rendering(){
fpsHistory = new ArrayList<>(100);
......@@ -40,7 +43,7 @@ public class Rendering {
// Draw my tank;
try {
image1 = ImageIO.read(new File(setting.getTankShapePath()));
image1 = ImageIO.read(new File(SettingPanel.setting.getTankShapePath()));
} catch (IOException e) {
System.out.println(e);
}
......@@ -149,9 +152,14 @@ public class Rendering {
g2d.drawImage(op2.filter((BufferedImage) explosionImg, null), myTank.locX, myTank.locY, null);
myTank.setTankLife(0);
myTank.gameOver = true;
if (flag) {
System.out.println(MainPanel.startTimeForSetting + "********"+ System.currentTimeMillis());
SettingPanel.setting.updateSettingAfterASingleGame(MainPanel.startTimeForSetting, System.currentTimeMillis(), false);
System.out.println(MainPanel.startTimeForSetting + "********"+ System.currentTimeMillis());
flag = false;
}
}
} else if ((bullet.locX > myTank.locX - 20 && bullet.locX < myTank.locX + 20 && bullet.locY > myTank.locY - 10 && bullet.locY < myTank.locY + 10) && !myTank.hasShield() && System.currentTimeMillis() - bullet.getCreateTime() > 100 && myTank.isHasMoreLife()) {
System.out.println("has ");
myTank.setHasMoreLife(false);
if (myTank.getTankLife() > 100)
myTank.setTankLife(myTank.getTankLife() - 10);
......@@ -169,6 +177,9 @@ public class Rendering {
g2d.drawImage(op2.filter((BufferedImage) explosionImg, null), enemyTank.locX, enemyTank.locY, null);
enemyTank.setTankLife(0);
enemyTank.gameOver = true;
if (flag){
SettingPanel.setting.updateSettingAfterASingleGame(MainPanel.startTimeForSetting , System.currentTimeMillis() ,true);}
flag = false;
}
}
}
......
......@@ -20,6 +20,8 @@ import java.net.UnknownHostException;
public class MainPanel extends JPanel {
private Image image;
public static boolean singlePlay;
public static long startTimeForSetting;
public MainPanel() throws IOException {
image = ImageIO.read(new File("C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\index.png"));
......@@ -48,6 +50,9 @@ public class MainPanel extends JPanel {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
singlePlay =true;
long x = System.currentTimeMillis();
startTimeForSetting = x ;
run();
}
......@@ -60,6 +65,7 @@ public class MainPanel extends JPanel {
Client1 client1 = null;
try {
client1 = new Client1(InetAddress.getLocalHost().getHostName(),5001);
startTimeForSetting =System.currentTimeMillis();
run2(client1);
} catch (UnknownHostException ex) {
ex.printStackTrace();
......@@ -133,9 +139,7 @@ public class MainPanel extends JPanel {
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("222222 after init");
ThreadPool.execute(game);
System.out.println("after thearsd");
// and the game starts ...
}
});
......
......@@ -47,8 +47,9 @@ import java.util.ArrayList;
*/
public void init() throws IOException {
// Perform all initializations ...
myTank = new MyTank(client1.getWallState());
client1.run1wall();
System.out.println(client1.getWallState());
myTank = new MyTank(client1.getWallState());
client1.runToUpdateTank(myTank);
enemyTanks = client1.createEnemyTanks();
canvas.addKeyListener(myTank.getMyListener());
......
......@@ -3,6 +3,7 @@ package UI.LogIn.NetWorkGame;
import Server_Client.NetWorkGame.Client1;
import UI.GameState.*;
import UI.LogIn.Game.GameLoop;
import UI.LogIn.MainPanel;
import UI.LogIn.Setting;
import javax.imageio.ImageIO;
......@@ -157,7 +158,6 @@ public class NWGRendering {
myTank.gameOver = true;
}
} else if ((bullet.locX > myTank.locX - 20 && bullet.locX < myTank.locX + 20 && bullet.locY > myTank.locY - 10 && bullet.locY < myTank.locY + 10) && !myTank.hasShield() && System.currentTimeMillis() - bullet.getCreateTime() > 100 && myTank.isHasMoreLife()) {
System.out.println("has ");
myTank.setHasMoreLife(false);
if (myTank.getTankLife() > 100)
myTank.setTankLife(myTank.getTankLife() - 10);
......
......@@ -6,7 +6,7 @@ import javax.swing.*;
import java.util.ArrayList;
public class Setting {
private float playedTime = 0;
private long playedTime = 0;
private String userName = InitialPanel.userName.getText() ;
private int numOfWinsSingle = 0;
private int numOfLoosesSingle = 0;
......@@ -19,13 +19,14 @@ public class Setting {
private ArrayList<String> urls = new ArrayList<>();
public void updateSettingAfterASingleGame(float startTime , float endTime , boolean isWin ){
public void updateSettingAfterASingleGame(long startTime , long endTime , boolean isWin ){
System.out.println(endTime +" "+ startTime);
playedTime += endTime - startTime ;
if (isWin)numOfWinsSingle++;
else numOfLoosesSingle++;
}
public void updateSettingAfterAMultiGame(float startTime , float endTime , boolean isWin ){
public void updateSettingAfterAMultiGame(long startTime , long endTime , boolean isWin ){
playedTime += endTime - startTime ;
if (isWin)numOfWinsMulti++;
else numOfLoosesMulti++;
......@@ -40,7 +41,7 @@ public class Setting {
return numOfLoosesMulti;
}
public float getPlayedTime() {
public long getPlayedTime() {
return playedTime;
}
......
......@@ -12,7 +12,7 @@ import java.io.IOException;
public class SettingPanel extends JPanel {
private Setting setting = new Setting();
public static Setting setting = new Setting();
private String chosenTankPath ="C:\\Users\\Lenovo\\IdeaProjects\\JTankTrouble\\pics\\tank_blue.png";
private Image image;
......
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