This commit is contained in:
Pan 2019-05-23 08:15:50 +12:00
parent ce5a72c85b
commit 958e6c720b
5 changed files with 68 additions and 19 deletions

1
core/.gitignore vendored
View File

@ -20,3 +20,4 @@
/vector.class /vector.class
/playerCommander.class /playerCommander.class
/sideBarManager.class /sideBarManager.class
/highscoreManager.class

View File

@ -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++;
}
}
}

View File

@ -12,7 +12,7 @@ import javax.swing.JPanel;
import enemyAI.*; import enemyAI.*;
import gui.*; import gui.*;
import java.sql.*;
public class mainThread extends JFrame implements KeyListener, ActionListener, MouseMotionListener, MouseListener, FocusListener{ 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(){ 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"); setTitle("Battle Tank 3");
panel= (JPanel) this.getContentPane(); panel= (JPanel) this.getContentPane();
panel.setPreferredSize(new Dimension(768, 512)); panel.setPreferredSize(new Dimension(768, 512));

View File

@ -120,6 +120,11 @@ public class postProcessingThread implements Runnable{
public static vector eyeDirection; public static vector eyeDirection;
public static void init(){ public static void init(){
//init game menu
theGameMenu = new gameMenu();
theGameMenu.init();
//create font bitmaps //create font bitmaps
theTextRenderer = new textRenderer(); theTextRenderer = new textRenderer();
theTextRenderer.init(); theTextRenderer.init();
@ -140,11 +145,6 @@ public class postProcessingThread implements Runnable{
theSideBar = new SideBar(); theSideBar = new SideBar();
theSideBar.init(); theSideBar.init();
//init game menu
theGameMenu = new gameMenu();
theGameMenu.init();
unitInfoTable = new int[201][4]; unitInfoTable = new int[201][4];
// Max health Health_bar Length Health_bar Xpos Health_bar yPos // Max health Health_bar Length Health_bar Xpos Health_bar yPos

View File

@ -23,7 +23,7 @@ public class gameMenu {
public int[] titleImage, lightTankImage, rocketTankImage, stealthTankImage, heavyTankImage; 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; enableMouseCapture, disableMouseCapture, enableFogOfWar, disableFogOfWar;
public char[] easyDescription, normalDescription, hardDescription, helpPage1, helpPage2, helpPage3, helpPage4, mouseMode; public char[] easyDescription, normalDescription, hardDescription, helpPage1, helpPage2, helpPage3, helpPage4, mouseMode;
@ -32,6 +32,8 @@ public class gameMenu {
public ArrayList<button> buttons = new ArrayList<button>(); public ArrayList<button> buttons = new ArrayList<button>();
public highscoreManager theHighscoreManager;
public void init() { public void init() {
if(titleImage == null) { if(titleImage == null) {
titleImage = new int[288*46]; titleImage = new int[288*46];
@ -43,7 +45,9 @@ public class gameMenu {
if(screenBlurBuffer == null) if(screenBlurBuffer == null)
screenBlurBuffer = new int[512 * 768]; screenBlurBuffer = new int[512 * 768];
theHighscoreManager = new highscoreManager();
Thread t = new Thread(theHighscoreManager);
t.start();
String folder = "../images/"; String folder = "../images/";
loadTexture(folder + "title.png", titleImage, 216, 35); loadTexture(folder + "title.png", titleImage, 216, 35);
@ -65,6 +69,9 @@ public class gameMenu {
showOptions = new button("showOptions", "Options", 324, 210, 120, 28); showOptions = new button("showOptions", "Options", 324, 210, 120, 28);
buttons.add(showOptions); buttons.add(showOptions);
showHighscores = new button("showHighscores", "Highscores", 324, 260, 120, 28);
buttons.add(showHighscores);
quitGame = new button("quitGame", "Quit Game", 324, 345, 120, 28); quitGame = new button("quitGame", "Quit Game", 324, 345, 120, 28);
buttons.add(quitGame); buttons.add(quitGame);
@ -213,6 +220,7 @@ public class gameMenu {
showHelp.display = true; showHelp.display = true;
showOptions.display = true; showOptions.display = true;
showHighscores.display = true;
}else if(menuStatus == difficulitySelectionMenu) { }else if(menuStatus == difficulitySelectionMenu) {
if(postProcessingThread.escapeKeyPressed) { if(postProcessingThread.escapeKeyPressed) {