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;
import java.io.FileWriter;
public class CreateNewGameFrame extends JFrame {
private JPanel settingPanel;
private JPanel gameDetailsPanel;
private JPanel optionPanel;
......@@ -49,7 +50,7 @@ public class CreateNewGameFrame extends JFrame {
destructibleWallSlider = new JSlider(10, 100, 20);
sliderAndIcon(tankHealthSlider, "pictures/tankHealth.png");
sliderAndIcon(shotDamageSlider, "pictures/shotDamage.png");
sliderAndIcon(destructibleWallSlider, "pictures/DestructibleWall.png");
sliderAndIcon(destructibleWallSlider,"pictures/DestructibleWall.png");
add(settingPanel);
settingPanel.add(gameDetailsPanel, BorderLayout.CENTER);
......@@ -136,6 +137,4 @@ public class CreateNewGameFrame extends JFrame {
ex.printStackTrace();
}
}
}
......@@ -71,7 +71,8 @@ public class GameLoop implements Runnable {
long delay = (1000 / FPS) - (System.currentTimeMillis() - start);
if (delay > 0)
Thread.sleep(delay);
} catch (InterruptedException | IOException | AWTException ex) {
} catch (Exception ee) {
ee.printStackTrace();
}
}
try {
......
......@@ -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() {
tankPhoto = new ImageIcon("gifFiles/gif.gif");
......@@ -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() {
File accounts = new File("Accounts.txt");
try (Scanner scanner = new Scanner(new FileReader(accounts))) {
......@@ -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) {
try (FileWriter fileWriter = new FileWriter(accounts, true)) {
fileWriter.write(userName.getText() + " " + passwordField.getText() + " " + remindMe.isSelected() + " 0 0 0 0 0 " + "\n");
......@@ -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 {
}
}
class OfflineModeAction implements ActionListener {
class OfflineModeAction implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
......@@ -115,7 +114,7 @@ public class MainFrame extends JFrame {
JFrame dialogFrame = new JFrame("Change settings ");
dialogFrame.setResizable(false);
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 ?");
dialogFrame.add(settingLabel);
......@@ -143,10 +142,8 @@ public class MainFrame extends JFrame {
dialogFrame.setVisible(true);
}
}
class OnlineModeAction implements ActionListener {
class OnlineModeAction implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
......@@ -155,4 +152,4 @@ public class MainFrame extends JFrame {
}
}
\ No newline at end of file
}
......@@ -8,6 +8,7 @@ import java.io.FileReader;
import java.util.Scanner;
public class OnlineModeFrame extends JFrame {
private JComboBox serverBox;
private JPanel serverChoosePanel;
private JPanel gamesPanel;
......@@ -98,6 +99,4 @@ public class OnlineModeFrame extends JFrame {
new CreateNewGameFrame("Make A New Game");
}
}
}
......@@ -29,6 +29,7 @@ public class SettingFrame extends JFrame {
setVisible(true);
}
public void initUserInformationPanel() {
userInformationPanel = new JPanel();
......@@ -68,7 +69,9 @@ public class SettingFrame extends JFrame {
add(userInformationPanel);
}
public void textAndLabel(String pngFile, String textField) {
ImageIcon icon = new ImageIcon(pngFile);
......@@ -84,6 +87,7 @@ public class SettingFrame extends JFrame {
userInformationPanel.add(text);
}
public void initSettingPanel() {
settingPanel = new JPanel();
......@@ -104,6 +108,7 @@ public class SettingFrame extends JFrame {
settingPanel.add(gameDetailsPanel, BorderLayout.NORTH);
settingPanel.add(serverPanel, BorderLayout.CENTER);
}
public void initServerPanel() {
JComboBox serverBox = new JComboBox();
serverBox.addItem("Server 1");
......@@ -138,8 +143,4 @@ public class SettingFrame extends JFrame {
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