Commit d875d70a authored by 9831111's avatar 9831111 🙂

Merge branch 'master' of /Users/sepehr/Desktop/JTankTrouble-N with conflicts.

parent e293ef66
...@@ -8,6 +8,7 @@ import java.io.File; ...@@ -8,6 +8,7 @@ import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
public class CreateNewGameFrame extends JFrame { public class CreateNewGameFrame extends JFrame {
private JPanel settingPanel; private JPanel settingPanel;
private JPanel gameDetailsPanel; private JPanel gameDetailsPanel;
private JPanel optionPanel; private JPanel optionPanel;
...@@ -49,7 +50,7 @@ public class CreateNewGameFrame extends JFrame { ...@@ -49,7 +50,7 @@ public class CreateNewGameFrame extends JFrame {
destructibleWallSlider = new JSlider(10, 100, 20); destructibleWallSlider = new JSlider(10, 100, 20);
sliderAndIcon(tankHealthSlider, "pictures/tankHealth.png"); sliderAndIcon(tankHealthSlider, "pictures/tankHealth.png");
sliderAndIcon(shotDamageSlider, "pictures/shotDamage.png"); sliderAndIcon(shotDamageSlider, "pictures/shotDamage.png");
sliderAndIcon(destructibleWallSlider, "pictures/DestructibleWall.png"); sliderAndIcon(destructibleWallSlider,"pictures/DestructibleWall.png");
add(settingPanel); add(settingPanel);
settingPanel.add(gameDetailsPanel, BorderLayout.CENTER); settingPanel.add(gameDetailsPanel, BorderLayout.CENTER);
...@@ -136,6 +137,4 @@ public class CreateNewGameFrame extends JFrame { ...@@ -136,6 +137,4 @@ public class CreateNewGameFrame extends JFrame {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
} }
...@@ -71,7 +71,8 @@ public class GameLoop implements Runnable { ...@@ -71,7 +71,8 @@ public class GameLoop implements Runnable {
long delay = (1000 / FPS) - (System.currentTimeMillis() - start); long delay = (1000 / FPS) - (System.currentTimeMillis() - start);
if (delay > 0) if (delay > 0)
Thread.sleep(delay); Thread.sleep(delay);
} catch (InterruptedException | IOException | AWTException ex) { } catch (Exception ee) {
ee.printStackTrace();
} }
} }
try { try {
......
...@@ -35,20 +35,6 @@ public class LoginFrame extends JFrame { ...@@ -35,20 +35,6 @@ public class LoginFrame extends JFrame {
} }
public void initInformationPanel() {
informationPanel = new JPanel();
informationPanel.setOpaque(true);
informationPanel.setBorder(new LineBorder(Color.DARK_GRAY));
informationPanel.setLayout(new GridLayout(3, 1));
informationPanel.add(userName);
informationPanel.add(passwordField);
informationPanel.add(remindMe);
add(informationPanel, BorderLayout.CENTER);
}
public void initLoginFrame() { public void initLoginFrame() {
tankPhoto = new ImageIcon("gifFiles/gif.gif"); tankPhoto = new ImageIcon("gifFiles/gif.gif");
...@@ -81,6 +67,20 @@ public class LoginFrame extends JFrame { ...@@ -81,6 +67,20 @@ public class LoginFrame extends JFrame {
} }
public void initInformationPanel() {
informationPanel = new JPanel();
informationPanel.setOpaque(true);
informationPanel.setBorder(new LineBorder(Color.DARK_GRAY));
informationPanel.setLayout(new GridLayout(3, 1));
informationPanel.add(userName);
informationPanel.add(passwordField);
informationPanel.add(remindMe);
add(informationPanel, BorderLayout.CENTER);
}
public void initRemindMe() { public void initRemindMe() {
File accounts = new File("Accounts.txt"); File accounts = new File("Accounts.txt");
try (Scanner scanner = new Scanner(new FileReader(accounts))) { try (Scanner scanner = new Scanner(new FileReader(accounts))) {
...@@ -99,6 +99,28 @@ public class LoginFrame extends JFrame { ...@@ -99,6 +99,28 @@ public class LoginFrame extends JFrame {
} }
} }
class SignUpAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
File accounts = new File("Accounts.txt");
try (Scanner scanner = new Scanner(new FileReader(accounts))) {
String account = "";
while (scanner.hasNextLine()) {
account = scanner.nextLine() + "\n";
}
if (account.contains(userName.getText())) {
JFrame userFound = new JFrame();
JOptionPane.showMessageDialog(userFound, "This User already exists ! ", "", JOptionPane.ERROR_MESSAGE);
} else {
signUpUser(accounts);
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
}
public void signUpUser(File accounts) { public void signUpUser(File accounts) {
try (FileWriter fileWriter = new FileWriter(accounts, true)) { try (FileWriter fileWriter = new FileWriter(accounts, true)) {
fileWriter.write(userName.getText() + " " + passwordField.getText() + " " + remindMe.isSelected() + " 0 0 0 0 0 " + "\n"); fileWriter.write(userName.getText() + " " + passwordField.getText() + " " + remindMe.isSelected() + " 0 0 0 0 0 " + "\n");
...@@ -146,27 +168,4 @@ public class LoginFrame extends JFrame { ...@@ -146,27 +168,4 @@ public class LoginFrame extends JFrame {
} }
} }
class SignUpAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
File accounts = new File("Accounts.txt");
try (Scanner scanner = new Scanner(new FileReader(accounts))) {
String account = "";
while (scanner.hasNextLine()) {
account = scanner.nextLine() + "\n";
}
if (account.contains(userName.getText())) {
JFrame userFound = new JFrame();
JOptionPane.showMessageDialog(userFound, "This User already exists ! ", "", JOptionPane.ERROR_MESSAGE);
} else {
signUpUser(accounts);
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
}
} }
...@@ -106,8 +106,7 @@ public class MainFrame extends JFrame { ...@@ -106,8 +106,7 @@ public class MainFrame extends JFrame {
} }
} }
class OfflineModeAction implements ActionListener{
class OfflineModeAction implements ActionListener {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
...@@ -115,7 +114,7 @@ public class MainFrame extends JFrame { ...@@ -115,7 +114,7 @@ public class MainFrame extends JFrame {
JFrame dialogFrame = new JFrame("Change settings "); JFrame dialogFrame = new JFrame("Change settings ");
dialogFrame.setResizable(false); dialogFrame.setResizable(false);
dialogFrame.setLayout(new FlowLayout()); dialogFrame.setLayout(new FlowLayout());
dialogFrame.setBounds(700, 450, 300, 85); dialogFrame.setBounds(700,450,300,85);
JLabel settingLabel = new JLabel("Do you want to play with current setting ?"); JLabel settingLabel = new JLabel("Do you want to play with current setting ?");
dialogFrame.add(settingLabel); dialogFrame.add(settingLabel);
...@@ -143,10 +142,8 @@ public class MainFrame extends JFrame { ...@@ -143,10 +142,8 @@ public class MainFrame extends JFrame {
dialogFrame.setVisible(true); dialogFrame.setVisible(true);
} }
} }
class OnlineModeAction implements ActionListener{
class OnlineModeAction implements ActionListener {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
......
...@@ -8,6 +8,7 @@ import java.io.FileReader; ...@@ -8,6 +8,7 @@ import java.io.FileReader;
import java.util.Scanner; import java.util.Scanner;
public class OnlineModeFrame extends JFrame { public class OnlineModeFrame extends JFrame {
private JComboBox serverBox; private JComboBox serverBox;
private JPanel serverChoosePanel; private JPanel serverChoosePanel;
private JPanel gamesPanel; private JPanel gamesPanel;
...@@ -98,6 +99,4 @@ public class OnlineModeFrame extends JFrame { ...@@ -98,6 +99,4 @@ public class OnlineModeFrame extends JFrame {
new CreateNewGameFrame("Make A New Game"); new CreateNewGameFrame("Make A New Game");
} }
} }
} }
...@@ -29,6 +29,7 @@ public class SettingFrame extends JFrame { ...@@ -29,6 +29,7 @@ public class SettingFrame extends JFrame {
setVisible(true); setVisible(true);
} }
public void initUserInformationPanel() { public void initUserInformationPanel() {
userInformationPanel = new JPanel(); userInformationPanel = new JPanel();
...@@ -68,7 +69,9 @@ public class SettingFrame extends JFrame { ...@@ -68,7 +69,9 @@ public class SettingFrame extends JFrame {
add(userInformationPanel); add(userInformationPanel);
} }
public void textAndLabel(String pngFile, String textField) { public void textAndLabel(String pngFile, String textField) {
ImageIcon icon = new ImageIcon(pngFile); ImageIcon icon = new ImageIcon(pngFile);
...@@ -84,6 +87,7 @@ public class SettingFrame extends JFrame { ...@@ -84,6 +87,7 @@ public class SettingFrame extends JFrame {
userInformationPanel.add(text); userInformationPanel.add(text);
} }
public void initSettingPanel() { public void initSettingPanel() {
settingPanel = new JPanel(); settingPanel = new JPanel();
...@@ -104,6 +108,7 @@ public class SettingFrame extends JFrame { ...@@ -104,6 +108,7 @@ public class SettingFrame extends JFrame {
settingPanel.add(gameDetailsPanel, BorderLayout.NORTH); settingPanel.add(gameDetailsPanel, BorderLayout.NORTH);
settingPanel.add(serverPanel, BorderLayout.CENTER); settingPanel.add(serverPanel, BorderLayout.CENTER);
} }
public void initServerPanel() { public void initServerPanel() {
JComboBox serverBox = new JComboBox(); JComboBox serverBox = new JComboBox();
serverBox.addItem("Server 1"); serverBox.addItem("Server 1");
...@@ -138,8 +143,4 @@ public class SettingFrame extends JFrame { ...@@ -138,8 +143,4 @@ public class SettingFrame extends JFrame {
gameDetailsPanel.add(slider); gameDetailsPanel.add(slider);
} }
} }
public class temp {
// if(Math.abs((locX+5-wall.getX()))<18 && Math.abs((locY-wall.getY()))<18){
// System.out.println("4");
// Permission = false;
// break;
// }
//if (locX + 5 < wall.getX() && locY + 5 < wall.getY() && locX - 5 < wall.getX() && locY - 5 < wall.getY())
// {
// System.out.println("1111");
// if (Math.abs(locY - wall.getY()) <= 25 && Math.abs(wall.getX() - locX) <= 25 && (rotateAmount == 90 || rotateAmount == -270)) {
// System.out.println("1");
// Permission = false;
// break;
// }
// if (Math.abs((locX - wall.getX())) <= 25 && Math.abs((locY-wall.getY()))<=25 && rotateAmount == 0) {
// System.out.println("2");
// Permission = false;
// break;
// }
// if ( Math.abs(locX - wall.getX()) <=30 && Math.abs(locY-wall.getY())<=75 && (rotateAmount == -180 || rotateAmount == 180)) {
// System.out.println("3");
// Permission = false;
// break;
// }
// if((rotateAmount==-270||rotateAmount==90)&& Math.abs((locX-wall.getX()))<=25 && Math.abs(locY-wall.getY())<=25){
// System.out.println("4");
// Permission = false;
// break;
// }
// }
// if (!robot.getPixelColor(locX + 5, locY + 5).equals(robot.getPixelColor(locX,locY)) ||
// robot.getPixelColor(locX + 5, locY + 5).equals(robot.getPixelColor(locX,locY))) {
// //System.out.println((locX + 5, locY + 5));
// // System.out.println(robot.getPixelColor(locX , locY ));
// System.out.println("4");
// Permission = false;
// break;
// }
// System.out.println("na");
// if(Controller.g2d.hit( wall, (Shape) Controller.taken,false)){
// System.out.println("4");
// Permission = false;
// break;
// }
// boolean Permission = true;
// for (Wall wall : Controller.walls) {
// if ((wall.getX() == locX + 5 || wall.getX() == locX + 5 + 5)) {
// Permission = false;
// break;
// }
// }
// Robot robot = new Robot();
// if (!robot.getPixelColor(locX + 5, locY + 5).equals(robot.getPixelColor(locX,locY)) ||
// robot.getPixelColor(locX + 5, locY + 5).equals(robot.getPixelColor(locX,locY))) {
// System.out.println("4");
// Permission = false;
// break;
// }
}
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