This commit is contained in:
Pan Hu 2019-05-23 16:48:40 +12:00
parent 958e6c720b
commit 3bdf85da14
3 changed files with 57 additions and 7 deletions

View File

@ -4,13 +4,21 @@ import java.sql.*;
public class highscoreManager implements Runnable{
public Connection connect;
public int status;
public int counter;
public int status;
public static final int idle = 0;
public static final int processing = 1;
public static final int error = 2;
public int task;
public static final int none = 0;
public static final int loadHighscores = 1;
public boolean isSleeping;
public String[] result;
public highscoreManager(){
status = processing;
}
@ -36,14 +44,25 @@ public class highscoreManager implements Runnable{
if(status == idle) {
if(task != none) {
status = processing;
//get high scroes from remote database
result = new String[] {};
status = idle;
task = none;
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
counter++;
}

View File

@ -13,7 +13,6 @@ import javax.swing.JPanel;
import enemyAI.*;
import gui.*;
public class mainThread extends JFrame implements KeyListener, ActionListener, MouseMotionListener, MouseListener, FocusListener{
public static int[] screen, bufferScreen;
@ -69,7 +68,6 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
public static int mouseX, mouseY, centerScreenX, centerScreenY, currentMouseX, currentMouseY;
public mainThread(){
setTitle("Battle Tank 3");
panel= (JPanel) this.getContentPane();
panel.setPreferredSize(new Dimension(768, 512));
@ -228,9 +226,6 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
currentMouseX = MouseInfo.getPointerInfo().getLocation().x;
currentMouseY = MouseInfo.getPointerInfo().getLocation().y;
centerScreenX = getLocationOnScreen().x + 384;
centerScreenY = getLocationOnScreen().y + 256;
int deltaX = currentMouseX - centerScreenX;
int deltaY = currentMouseY - centerScreenY;

View File

@ -16,6 +16,7 @@ public class gameMenu {
public static final int helpMenu = 2;
public static final int endGameMenu = 3;
public static final int optionMenu = 4;
public static final int highscoreMenu = 5;
public int[] screen;
public int[] screenBlurBuffer;
@ -29,6 +30,7 @@ public class gameMenu {
public char[] easyDescription, normalDescription, hardDescription, helpPage1, helpPage2, helpPage3, helpPage4, mouseMode;
public int currentHelpPage;
public int highscoreLevel;
public ArrayList<button> buttons = new ArrayList<button>();
@ -49,6 +51,8 @@ public class gameMenu {
Thread t = new Thread(theHighscoreManager);
t.start();
highscoreLevel = 1;
String folder = "../images/";
loadTexture(folder + "title.png", titleImage, 216, 35);
loadTexture(folder + "58.jpg", lightTankImage, 44, 44);
@ -324,6 +328,31 @@ public class gameMenu {
}
}
}else if(menuStatus == highscoreMenu) {
if(postProcessingThread.escapeKeyPressed) {
menuStatus = mainMenu;
theHighscoreManager.task = theHighscoreManager.none;
if(theHighscoreManager.status == theHighscoreManager.idle) {
theHighscoreManager.result = null;
}
}else {
drawTitle();
drawMenuFrame(420, 360);
if(theHighscoreManager.status == theHighscoreManager.processing) {
drawLoadingScreen(screen);
}else if(theHighscoreManager.status == theHighscoreManager.idle) {
if(theHighscoreManager.task == theHighscoreManager.none && theHighscoreManager.result == null) {
theHighscoreManager.task = theHighscoreManager.loadHighscores;
drawLoadingScreen(screen);
}else if(theHighscoreManager.task == theHighscoreManager.none && theHighscoreManager.result != null) {
//draw high scores
}
}else if(theHighscoreManager.status == theHighscoreManager.error) {
}
}
}
@ -332,6 +361,11 @@ public class gameMenu {
}
public void drawLoadingScreen(int[] screen) {
textRenderer tRenderer = postProcessingThread.theTextRenderer;
tRenderer.drawMenuText(82,90,"busy".toCharArray(), screen, 255,255,255,0);
}
public void updateButtons() {
for(int i = 0; i < buttons.size(); i++) {
if(buttons.get(i).checkIfCursorIsOnTop(postProcessingThread.mouse_x, postProcessingThread.mouse_y)) {
@ -351,6 +385,8 @@ public class gameMenu {
currentHelpPage++;
}else if(buttons.get(i).name == "previousPage") {
currentHelpPage--;
}else if(buttons.get(i).name == "showHighscores") {
menuStatus = highscoreMenu;
}
postProcessingThread.buttonAction = buttons.get(i).name;