From 958e6c720bf1c7dff03d216bef2dc8703d0b3444 Mon Sep 17 00:00:00 2001 From: Pan Date: Thu, 23 May 2019 08:15:50 +1200 Subject: [PATCH] h --- core/.gitignore | 1 + core/highscoreManager.java | 51 ++++++++++++++++++++++++++++++++++ core/mainThread.java | 13 +-------- core/postProcessingThread.java | 10 +++---- gui/gameMenu.java | 12 ++++++-- 5 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 core/highscoreManager.java diff --git a/core/.gitignore b/core/.gitignore index fbd5135..4c81db8 100644 --- a/core/.gitignore +++ b/core/.gitignore @@ -20,3 +20,4 @@ /vector.class /playerCommander.class /sideBarManager.class +/highscoreManager.class diff --git a/core/highscoreManager.java b/core/highscoreManager.java new file mode 100644 index 0000000..a6e97d9 --- /dev/null +++ b/core/highscoreManager.java @@ -0,0 +1,51 @@ +package core; + +import java.sql.*; + +public class highscoreManager implements Runnable{ + public Connection connect; + public int status; + public int counter; + public static final int idle = 0; + public static final int processing = 1; + public static final int error = 2; + + + public highscoreManager(){ + status = processing; + } + + + @Override + public void run() { + // TODO Auto-generated method stub + while(true) { + if(counter == 0) { + try { + + connect = DriverManager.getConnection("jdbc:mysql://remotemysql.com/TDYAgrQ1Ny?useSSL=false", "TDYAgrQ1Ny", "SrexYcsOSv"); + + status = idle; + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + status = error; + } + } + + if(status == idle) { + + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + counter++; + } + + } +} diff --git a/core/mainThread.java b/core/mainThread.java index de4b4b0..55cef86 100644 --- a/core/mainThread.java +++ b/core/mainThread.java @@ -12,7 +12,7 @@ import javax.swing.JPanel; import enemyAI.*; import gui.*; -import java.sql.*; + public class mainThread extends JFrame implements KeyListener, ActionListener, MouseMotionListener, MouseListener, FocusListener{ @@ -70,17 +70,6 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M public mainThread(){ - try { - Class.forName("com.mysql.jdbc.Driver"); - Connection connect = DriverManager.getConnection("jdbc:mysql://remotemysql.com/TDYAgrQ1Ny?useSSL=false", "TDYAgrQ1Ny", "SrexYcsOSv"); - - connect.close(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - setTitle("Battle Tank 3"); panel= (JPanel) this.getContentPane(); panel.setPreferredSize(new Dimension(768, 512)); diff --git a/core/postProcessingThread.java b/core/postProcessingThread.java index db52ab4..2e0bcf6 100644 --- a/core/postProcessingThread.java +++ b/core/postProcessingThread.java @@ -120,6 +120,11 @@ public class postProcessingThread implements Runnable{ public static vector eyeDirection; public static void init(){ + + //init game menu + theGameMenu = new gameMenu(); + theGameMenu.init(); + //create font bitmaps theTextRenderer = new textRenderer(); theTextRenderer.init(); @@ -140,11 +145,6 @@ public class postProcessingThread implements Runnable{ theSideBar = new SideBar(); theSideBar.init(); - //init game menu - theGameMenu = new gameMenu(); - theGameMenu.init(); - - unitInfoTable = new int[201][4]; // Max health Health_bar Length Health_bar Xpos Health_bar yPos diff --git a/gui/gameMenu.java b/gui/gameMenu.java index 13908fd..9cea146 100644 --- a/gui/gameMenu.java +++ b/gui/gameMenu.java @@ -23,7 +23,7 @@ public class gameMenu { public int[] titleImage, lightTankImage, rocketTankImage, stealthTankImage, heavyTankImage; - public button newGame, unpauseGame, showHelp, showOptions, quitGame, abortGame, easyGame, normalGame, hardGame, quitDifficulty, quitHelpMenu, quitOptionMenu, nextPage, previousPage, + public button newGame, unpauseGame, showHelp, showOptions, showHighscores, quitGame, abortGame, easyGame, normalGame, hardGame, quitDifficulty, quitHelpMenu, quitOptionMenu, nextPage, previousPage, enableMouseCapture, disableMouseCapture, enableFogOfWar, disableFogOfWar; public char[] easyDescription, normalDescription, hardDescription, helpPage1, helpPage2, helpPage3, helpPage4, mouseMode; @@ -32,6 +32,8 @@ public class gameMenu { public ArrayList