From b9cadc4863902e658054af322ae430d561265562 Mon Sep 17 00:00:00 2001 From: Pan Date: Sat, 25 May 2019 19:47:21 +1200 Subject: [PATCH] h --- core/AssetManager.java | 4 +- core/highscoreManager.java | 34 ++++- core/mainThread.java | 1 + core/postProcessingThread.java | 229 +++++++++++++++++---------------- entity/stealthTank.java | 6 +- gui/MiniMap.java | 6 +- gui/button.java | 3 +- gui/gameMenu.java | 134 +++++++++++++++++-- gui/inputHandler.java | 14 +- 9 files changed, 292 insertions(+), 139 deletions(-) diff --git a/core/AssetManager.java b/core/AssetManager.java index 8d1a715..d4e0ff3 100644 --- a/core/AssetManager.java +++ b/core/AssetManager.java @@ -250,13 +250,13 @@ public class AssetManager { //harvester l = new harvester(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0); //addHarvester(l); //l.hasMultiShotUpgrade = true; - lightTank l = new lightTank(new vector(i*0.25f + 1.125f,-0.3f, 0.5f + 4.625f + j*0.25f), 90, 0); + //lightTank l = new lightTank(new vector(i*0.25f + 27.125f,-0.3f, 0.5f + 26.625f + j*0.25f), 90, 0); //l.attackRange = 1.99f; //lightTank.tileCheckList_player = lightTank.generateTileCheckList(6); - addLightTank(l); + //addLightTank(l); //if(j == 0 && i == 0) //addMissileTurret(new missileTurret(i*0.25f -0.125f + 1, -0.65f, 0.25f + 17.125f + j*0.25f, 0)); diff --git a/core/highscoreManager.java b/core/highscoreManager.java index 1e9e1ff..9435724 100644 --- a/core/highscoreManager.java +++ b/core/highscoreManager.java @@ -14,13 +14,17 @@ public class highscoreManager implements Runnable{ public int task; public static final int none = 0; public static final int loadHighscores = 1; + public static final int uploadScore = 2; public boolean isSleeping; + public String playerName; + public String[][] result; public highscoreManager(){ status = processing; + playerName = ""; } @@ -57,7 +61,7 @@ public class highscoreManager implements Runnable{ stmt = connect.createStatement(); ResultSet rs=stmt.executeQuery("select * from highscore where skillLevel = 0 order by finishingTime"); while(rs.next()) { - String playerName = rs.getString(1); + playerName = rs.getString(1); if(!hasDuplicateName(0, numOfRows, myResult, playerName)) { myResult[numOfRows][0] = playerName; @@ -72,7 +76,7 @@ public class highscoreManager implements Runnable{ numOfRows = 10; rs=stmt.executeQuery("select * from highscore where skillLevel = 1 order by finishingTime"); while(rs.next()) { - String playerName = rs.getString(1); + playerName = rs.getString(1); if(!hasDuplicateName(10, numOfRows, myResult, playerName)) { myResult[numOfRows][0] = rs.getString(1); myResult[numOfRows][1] = secondsToString(rs.getInt(2)); @@ -86,7 +90,7 @@ public class highscoreManager implements Runnable{ numOfRows = 20; rs=stmt.executeQuery("select * from highscore where skillLevel = 2 order by finishingTime"); while(rs.next()) { - String playerName = rs.getString(1); + playerName = rs.getString(1); if(!hasDuplicateName(20, numOfRows, myResult, playerName)) { myResult[numOfRows][0] = rs.getString(1); myResult[numOfRows][1] = secondsToString(rs.getInt(2)); @@ -98,13 +102,35 @@ public class highscoreManager implements Runnable{ } result = myResult; + playerName =""; - } catch (SQLException e) { + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); status = error; result = null; + playerName = ""; } + }else if(task == uploadScore) { + + try { + + // the mysql insert statement + String query = " insert into highscore" + " values (?, ?, ?)"; + PreparedStatement preparedStmt = connect.prepareStatement(query); + + preparedStmt.setString (1, playerName); + preparedStmt.setInt (2, (int)(mainThread.gameFrame*0.025)); + preparedStmt.setInt (3, mainThread.ec.difficulty); + preparedStmt.execute(); + + + }catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + status = error; + playerName = ""; + } } if(status != error) diff --git a/core/mainThread.java b/core/mainThread.java index 6a7897c..0767f3f 100644 --- a/core/mainThread.java +++ b/core/mainThread.java @@ -66,6 +66,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M public static boolean capturedMouse, mouseLeftScreen, focusLost; public static int mouseX, mouseY, centerScreenX, centerScreenY, currentMouseX, currentMouseY; + public static char currentInputChar; public mainThread(){ setTitle("Battle Tank 3"); diff --git a/core/postProcessingThread.java b/core/postProcessingThread.java index e26d5d2..d2caaa5 100644 --- a/core/postProcessingThread.java +++ b/core/postProcessingThread.java @@ -75,7 +75,7 @@ public class postProcessingThread implements Runnable{ public static textRenderer theTextRenderer; - public static boolean gamePaused, gameStarted, playerVictory, AIVictory; + public static boolean gamePaused, gameStarted, playerVictory, AIVictory, afterMatch; public static int mouse_x, mouse_y; public static boolean leftMouseButtonReleased, escapeKeyPressed; @@ -85,6 +85,8 @@ public class postProcessingThread implements Runnable{ public static boolean fogOfWarDisabled; public static boolean capturedMouse; + public static char currentInputChar; + //A pool of vectors which will be used for vector arithmetic public static vector tempVector1 = new vector(0,0,0), @@ -561,123 +563,125 @@ public class postProcessingThread implements Runnable{ //reset fogOfWarBuffer - fogOfWarBuffer[0] = 0; - for(int i = 1; i < 393216; i+=i){ - System.arraycopy(fogOfWarBuffer, 0, fogOfWarBuffer, i, 393216 - i >= i ? i : 393216 - i); - - } - - for(int i = 0; i < 512; i++){ - xMin[i] = 378; - xMax[i] = 378; - - } - - float[] list; - //shaffule vision polygons - for(int i = 0; i < 400; i++){ - temp = (gameData.getRandom() * visionPolygonCount) >> 10; - temp1 = (gameData.getRandom() * visionPolygonCount) >> 10; - - list = visionPolygonInfo[temp]; - visionPolygonInfo[temp] = visionPolygonInfo[temp1]; - visionPolygonInfo[temp1] = list; - } - - //update vision polygons - for(int i = 0; i < visionPolygonCount; i++){ - tempVector1.set(visionPolygonInfo[i][1], visionPolygonInfo[i][2], visionPolygonInfo[i][3]); - if(visionPolygonInfo[i][0] != 0){ - poly = mainThread.theAssetManager.visionPolygon[1]; - }else{ - poly = mainThread.theAssetManager.visionPolygon[(int)visionPolygonInfo[i][4]]; - } - tempVector1.subtract(poly.centre); - for(int j = 0; j < 48; j++) - poly.vertex3D[j].add(tempVector1); - - - poly.centre.add(tempVector1); - poly.update_visionPolygon(); - - rasterize(poly); - } - - - - //blur fog of war buffer, use cross shaped kernel - int radius = 16; - int radiusBit = 5; - int destIndex = 0; - int index = 0; - for(int i = 0; i < 512; i++){ - //init the first element in the row - temp = 0; - destIndex = i + 512 * 767 ; - - for(int j = 0; j < radius -1; j++){ - temp+=fogOfWarBuffer[index + j]; - } - temp+=43*radius; - fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit); - index++; - destIndex-=512; - - for(int j = 1; j < radius; j++, index++, destIndex -=512){ - temp = temp + fogOfWarBuffer[index + radius -2] - 43; - fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit); - } - - for(int j = radius; j < 768 - radius; j++, index++, destIndex -=512){ - temp = temp + fogOfWarBuffer[index + radius -2] - fogOfWarBuffer[index - radius]; - fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit); + if(!afterMatch) { + fogOfWarBuffer[0] = 0; + for(int i = 1; i < 393216; i+=i){ + System.arraycopy(fogOfWarBuffer, 0, fogOfWarBuffer, i, 393216 - i >= i ? i : 393216 - i); } - for(int j = 0; j < radius; j++, index++, destIndex -=512){ - temp = temp - fogOfWarBuffer[index - radius] + 43; + + for(int i = 0; i < 512; i++){ + xMin[i] = 378; + xMax[i] = 378; + + } + + float[] list; + //shaffule vision polygons + for(int i = 0; i < 400; i++){ + temp = (gameData.getRandom() * visionPolygonCount) >> 10; + temp1 = (gameData.getRandom() * visionPolygonCount) >> 10; + + list = visionPolygonInfo[temp]; + visionPolygonInfo[temp] = visionPolygonInfo[temp1]; + visionPolygonInfo[temp1] = list; + } + + //update vision polygons + for(int i = 0; i < visionPolygonCount; i++){ + tempVector1.set(visionPolygonInfo[i][1], visionPolygonInfo[i][2], visionPolygonInfo[i][3]); + if(visionPolygonInfo[i][0] != 0){ + poly = mainThread.theAssetManager.visionPolygon[1]; + }else{ + poly = mainThread.theAssetManager.visionPolygon[(int)visionPolygonInfo[i][4]]; + } + tempVector1.subtract(poly.centre); + for(int j = 0; j < 48; j++) + poly.vertex3D[j].add(tempVector1); + + + poly.centre.add(tempVector1); + poly.update_visionPolygon(); + + rasterize(poly); + } + + + + //blur fog of war buffer, use cross shaped kernel + int radius = 16; + int radiusBit = 5; + int destIndex = 0; + int index = 0; + for(int i = 0; i < 512; i++){ + //init the first element in the row + temp = 0; + destIndex = i + 512 * 767 ; + + for(int j = 0; j < radius -1; j++){ + temp+=fogOfWarBuffer[index + j]; + } + temp+=43*radius; fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit); - } - } - - destIndex = 0; - index = 0; - for(int i = 0; i < 768; i++){ - //init the first element in the row - temp = 0; - destIndex = 767 - i; - - for(int j = 0; j < radius -1 ; j++){ - temp+=fogOfWarBuffer2[index + j]; - } - temp+=43*radius; - fogOfWarBuffer[destIndex] = (byte)(temp >> radiusBit); - index++; - destIndex+=768; - - for(int j = 1; j < radius; j++, index++, destIndex +=768){ - temp = temp + fogOfWarBuffer2[index + radius -2] - 43; - fogOfWarBuffer[destIndex] = (byte)(temp >> radiusBit); + index++; + destIndex-=512; + + for(int j = 1; j < radius; j++, index++, destIndex -=512){ + temp = temp + fogOfWarBuffer[index + radius -2] - 43; + fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit); + } + + for(int j = radius; j < 768 - radius; j++, index++, destIndex -=512){ + temp = temp + fogOfWarBuffer[index + radius -2] - fogOfWarBuffer[index - radius]; + fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit); + + } + for(int j = 0; j < radius; j++, index++, destIndex -=512){ + temp = temp - fogOfWarBuffer[index - radius] + 43; + fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit); + } } - for(int j = radius; j < 512 - radius; j++, index++, destIndex +=768){ - temp = temp + fogOfWarBuffer2[index + radius -2] - fogOfWarBuffer2[index - radius]; + destIndex = 0; + index = 0; + for(int i = 0; i < 768; i++){ + //init the first element in the row + temp = 0; + destIndex = 767 - i; + + for(int j = 0; j < radius -1 ; j++){ + temp+=fogOfWarBuffer2[index + j]; + } + temp+=43*radius; fogOfWarBuffer[destIndex] = (byte)(temp >> radiusBit); + index++; + destIndex+=768; + + for(int j = 1; j < radius; j++, index++, destIndex +=768){ + temp = temp + fogOfWarBuffer2[index + radius -2] - 43; + fogOfWarBuffer[destIndex] = (byte)(temp >> radiusBit); + } + + for(int j = radius; j < 512 - radius; j++, index++, destIndex +=768){ + temp = temp + fogOfWarBuffer2[index + radius -2] - fogOfWarBuffer2[index - radius]; + fogOfWarBuffer[destIndex] = (byte)(temp >> radiusBit); + } + for(int j = 0; j < radius; j++, index++, destIndex +=768){ + temp = temp - fogOfWarBuffer2[index - radius] + 43; + fogOfWarBuffer[destIndex] = (byte)(temp >> radiusBit); + } } - for(int j = 0; j < radius; j++, index++, destIndex +=768){ - temp = temp - fogOfWarBuffer2[index - radius] + 43; - fogOfWarBuffer[destIndex] = (byte)(temp >> radiusBit); - } - } - - - //blend fog of war to the frame buffer - for(int i = 0; i < 512 * 768; i++){ - temp = fogOfWarBuffer[i]; - if(temp < 112) { - r = (((currentScreen[i] & 0xff0000) >> 16) * (temp + 143)) >> 8; - g = (((currentScreen[i] & 0xff00) >> 8) * (temp + 143)) >> 8 ; - b = ((currentScreen[i] & 0xff) * (temp + 143)) >> 8; - currentScreen[i] = r << 16 | g << 8 | b; + + + //blend fog of war to the frame buffer + for(int i = 0; i < 512 * 768; i++){ + temp = fogOfWarBuffer[i]; + if(temp < 112) { + r = (((currentScreen[i] & 0xff0000) >> 16) * (temp + 143)) >> 8; + g = (((currentScreen[i] & 0xff00) >> 8) * (temp + 143)) >> 8 ; + b = ((currentScreen[i] & 0xff) * (temp + 143)) >> 8; + currentScreen[i] = r << 16 | g << 8 | b; + } } } @@ -969,11 +973,12 @@ public class postProcessingThread implements Runnable{ gameStarted = mainThread.gameStarted; playerVictory = mainThread.playerVictory; AIVictory = mainThread.AIVictory; + afterMatch = mainThread.afterMatch; timeString = mainThread.timeString; fogOfWarDisabled = mainThread.fogOfWarDisabled; capturedMouse = mainThread.capturedMouse; - + currentInputChar = mainThread.currentInputChar; currentScreen = mainThread.screen; diff --git a/entity/stealthTank.java b/entity/stealthTank.java index 00291fc..9dc0ca6 100644 --- a/entity/stealthTank.java +++ b/entity/stealthTank.java @@ -426,7 +426,7 @@ public class stealthTank extends solidObject{ if(isCloaked){ if(teamNo != 0){ - if(!mainThread.fogOfWarDisabled) + if(!mainThread.fogOfWarDisabled && !mainThread.afterMatch) if(currentCloakingStatus < 127) currentCloakingStatus+=3; }else{ @@ -556,10 +556,10 @@ public class stealthTank extends solidObject{ } //check if the tank object is visible in mini map - visible_minimap = theAssetManager.minimapBitmap[boundary2D.x1/16 + (127 - (boundary2D.y1-1)/16)*128] || mainThread.fogOfWarDisabled; + visible_minimap = theAssetManager.minimapBitmap[boundary2D.x1/16 + (127 - (boundary2D.y1-1)/16)*128] || mainThread.fogOfWarDisabled || mainThread.afterMatch; if(teamNo == 0 || attackStatus == isAttacking || exposedCountDown > 0 || visible_minimap){ - if(!(isCloaked && teamNo!=0) || mainThread.fogOfWarDisabled){ + if(!(isCloaked && teamNo!=0) || mainThread.fogOfWarDisabled || mainThread.afterMatch){ tempInt = theAssetManager.unitsForMiniMap[theAssetManager.unitsForMiniMapCount]; tempInt[0] = teamNo + (this.type << 8); tempInt[1] = boundary2D.x1/16; diff --git a/gui/MiniMap.java b/gui/MiniMap.java index 515eb3b..83c80ee 100644 --- a/gui/MiniMap.java +++ b/gui/MiniMap.java @@ -61,7 +61,7 @@ public class MiniMap { drawBackground(screen, minimapBitmap); //remove fog of war for testing - if(postProcessingThread.fogOfWarDisabled) + if(postProcessingThread.fogOfWarDisabled || postProcessingThread.afterMatch) for(int i = 0; i < minimapBitmap.length; i++) minimapBitmap[i] = true; @@ -304,6 +304,9 @@ public class MiniMap { for(int i = 0 ;i < tempBitmap.length; i++){ tempBitmap[i] = false; + + if(postProcessingThread.afterMatch) + tempBitmap[i] = true; } boolean[] vision; @@ -354,7 +357,6 @@ public class MiniMap { } - for(int y = 0; y < 128; y++){ for(int x = 0; x < 128; x++){ minimapBitmap[x + y*128] = tempBitmap[x + 10 + (y + 10)*148]; diff --git a/gui/button.java b/gui/button.java index 50d5fbb..436d048 100644 --- a/gui/button.java +++ b/gui/button.java @@ -11,6 +11,7 @@ public class button { public int actionCooldown; public int red, green, blue; public boolean disabled; + public boolean messageMode; public button(String name, String text, int xPos, int yPos, int width, int height) { this.name = name; @@ -30,7 +31,7 @@ public class button { } public void draw(int[] screen) { - if(disabled) { + if(disabled && !messageMode) { red = 55; green = 55; blue = 55; diff --git a/gui/gameMenu.java b/gui/gameMenu.java index e8686b0..3fd4cb7 100644 --- a/gui/gameMenu.java +++ b/gui/gameMenu.java @@ -27,7 +27,7 @@ public class gameMenu { public button newGame, unpauseGame, showHelp, showOptions, showHighscores, quitGame, abortGame, easyGame, normalGame, hardGame, quitDifficulty, quitHelpMenu, quitOptionMenu, quitHighscoreMenu, nextPage, previousPage, enableMouseCapture, disableMouseCapture, enableFogOfWar, disableFogOfWar, confirmErrorLoadingHighscore, normalToHardButton, normalToEasyButton, hardToNormalButton, easyToNormalButton, - backToMapDefeat, leaveGameDefeat; + backToMapDefeat, leaveGameDefeat, backToMapVictory, leaveGameVictory, uploadScore; public char[] easyDescription, normalDescription, hardDescription, helpPage1, helpPage2, helpPage3, helpPage4, mouseMode; @@ -38,6 +38,11 @@ public class gameMenu { public highscoreManager theHighscoreManager; + public char[] name; + public String nameString; + public static boolean uploadingScore, scoreUploaded; + + public void init() { if(titleImage == null) { titleImage = new int[288*46]; @@ -54,6 +59,9 @@ public class gameMenu { t.start(); highscoreLevel = 1; + name = new char[32]; + for(int i = 0; i< 32; i++) + name[i] = 255; String folder = "../images/"; loadTexture(folder + "title.png", titleImage, 216, 35); @@ -191,12 +199,21 @@ public class gameMenu { leaveGameDefeat = new button("abortGame", "Leave game", 440, 235, 120, 25); buttons.add(leaveGameDefeat); + + backToMapVictory = new button("backToMap", "Back to Map", 135, 315, 120, 25); + buttons.add(backToMapVictory); + + leaveGameVictory = new button("abortGame", "Leave game", 515, 315, 120, 25); + buttons.add(leaveGameVictory); + + uploadScore = new button("uploadScore", "Upload", 530, 250, 90, 25); + buttons.add(uploadScore); } public void updateAndDraw(int[] screen, boolean gameStarted, boolean gamePaused, boolean playerVictory, boolean AIVictory) { this.screen = screen; - + textRenderer tRenderer = postProcessingThread.theTextRenderer; if(gamePaused){ gameSuspendCount++; @@ -226,11 +243,103 @@ public class gameMenu { if(AIVictory) { drawMenuFrame(400, 100, 70); - textRenderer tRenderer = postProcessingThread.theTextRenderer; - tRenderer.drawMenuText(320,178,"You are Defeated! ".toCharArray(), screen, 255,255,255, 0); + tRenderer.drawMenuText(320,178,"You Are Defeated!".toCharArray(), screen, 255,255,255, 0); backToMapDefeat.display = true; leaveGameDefeat.display = true; + }else if(playerVictory) { + drawMenuFrame(550, 210, 40); + tRenderer.drawMenuText(320,138,"You are Victorious!".toCharArray(), screen, 255,255,255, 0); + + String difficulty = "Normal"; + if(mainThread.ec.difficulty == 0) + difficulty = "Easy"; + if(mainThread.ec.difficulty == 2) + difficulty = "Hard"; + tRenderer.drawMenuText(205,198,("Difficulty: "+ difficulty).toCharArray(), screen, 255,255,255, 0); + + String time = mainThread.timeString; + + tRenderer.drawMenuText(232,228,("Time: "+ time).toCharArray(), screen, 255,255,255, 0); + + + if(!postProcessingThread.fogOfWarDisabled) { + tRenderer.drawMenuText(185,258,("Your Name:").toCharArray(), screen, 255,255,255, 0); + uploadScore.display = true; + uploadScore.disabled = true; + + //only accept 0-9, A-Z, a-Z, space and backspace characters + char c = postProcessingThread.currentInputChar; + + if(!uploadingScore && !scoreUploaded) { + if((c >= 48 && c < 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c == 8 || c == 32) { + if(c == 8) { + for(int i = 31; i >= 0; i--) { + if(name[i] != 255) { + name[i] = 255; + break; + } + } + }else { + for(int i = 0; i < 32; i++) { + if(name[i] == 255) { + name[i] = c; + break; + } + } + } + } + } + + //check if upload condition is met + for(int i = 0; i < 32; i++) { + if((name[i] >= 48 && name[i] < 57) || (name[i] >= 65 && name[i] <= 90) || (name[i] >= 97 && name[i] <= 122)) { + uploadScore.disabled = false; + } + } + + //draw name string + nameString = ""; + for(int i = 0; i < 32; i++) { + if(name[i] != 255) { + nameString+=name[i]; + }else { + break; + } + } + tRenderer.drawText_outline(282, 258, nameString, screen, 0xdddddd, 0); + + //draw place marker + if(postProcessingThread.frameIndex%30 > 15 && !uploadingScore && !scoreUploaded) + tRenderer.drawText_outline(282+nameString.length()*7, 258, "_", screen, 0xdddddd, 0); + + if(uploadingScore || scoreUploaded) { + uploadScore.disabled = true; + } + + if(uploadingScore && !scoreUploaded) { + if(theHighscoreManager.status == theHighscoreManager.idle && theHighscoreManager.playerName.equals("")) { + theHighscoreManager.playerName = nameString; + theHighscoreManager.task = theHighscoreManager.uploadScore; + + }else if(theHighscoreManager.status == theHighscoreManager.error) { + + }else if(theHighscoreManager.status == theHighscoreManager.idle && theHighscoreManager.task== theHighscoreManager.none && !theHighscoreManager.playerName.equals("")) { + scoreUploaded = true; + theHighscoreManager.playerName = ""; + } + } + + if(scoreUploaded) { + uploadScore.text = "Uploaded!"; + uploadScore.theText = uploadScore.text.toCharArray(); + uploadScore.messageMode = true; + } + + } + + backToMapVictory.display = true; + leaveGameVictory.display = true; } updateButtons(); @@ -277,8 +386,7 @@ public class gameMenu { }else { drawTitle(); drawMenuFrame(420, 260); - - textRenderer tRenderer = postProcessingThread.theTextRenderer; + easyGame.display = true; tRenderer.drawMenuText(285,118,easyDescription, screen, 255,255,255, 0); @@ -304,8 +412,6 @@ public class gameMenu { drawTitle(); drawMenuFrame(620, 380); - textRenderer tRenderer = postProcessingThread.theTextRenderer; - if(currentHelpPage == 0) { tRenderer.drawMenuText(82,90,helpPage1, screen, 255,255,255,0); nextPage.display = true; @@ -342,7 +448,6 @@ public class gameMenu { drawTitle(); drawMenuFrame(520, 380); - textRenderer tRenderer = postProcessingThread.theTextRenderer; tRenderer.drawMenuText(135,95,mouseMode, screen, 255,255,255,0); if(postProcessingThread.capturedMouse == true) { @@ -384,8 +489,6 @@ public class gameMenu { drawTitle(); drawMenuFrame(420, 360); - textRenderer tRenderer = postProcessingThread.theTextRenderer; - if(theHighscoreManager.status == theHighscoreManager.processing) { drawLoadingScreen(screen); }else if(theHighscoreManager.status == theHighscoreManager.idle) { @@ -522,6 +625,15 @@ public class gameMenu { highscoreLevel = 0; }else if(buttons.get(i).name == "abortGame") { menuStatus = mainMenu; + for(int j = 0; j< 32; j++) + name[j] = 255; + scoreUploaded = false; + uploadingScore = false; + uploadScore.text = "Upload"; + uploadScore.theText = uploadScore.text.toCharArray(); + uploadScore.messageMode = false; + }else if(buttons.get(i).name == "uploadScore") { + uploadingScore = true; } postProcessingThread.buttonAction = buttons.get(i).name; diff --git a/gui/inputHandler.java b/gui/inputHandler.java index 22738db..31ce678 100644 --- a/gui/inputHandler.java +++ b/gui/inputHandler.java @@ -51,11 +51,13 @@ public class inputHandler { //read input char int theCounter = inputCounter; + mainThread.currentInputChar = 255; + //handle over flow if(inputBufferIndex > theCounter){ while(inputBufferIndex < 1024){ char c = inputBuffer[inputBufferIndex]; - + mainThread.currentInputChar = c; if(c == 's' || c == 'S'){ @@ -91,7 +93,7 @@ public class inputHandler { while(inputBufferIndex < theCounter){ char c = inputBuffer[inputBufferIndex]; - + mainThread.currentInputChar = c; if(c == 's' || c == 'S'){ S_pressed = true; @@ -124,6 +126,7 @@ public class inputHandler { if(keyReleaseBufferIndex > theCounter){ while(keyReleaseBufferIndex < 1024){ char c = keyReleaseBuffer[keyReleaseBufferIndex]; + if(c == 's' || c == 'S'){ S_pressed = false; } @@ -148,6 +151,7 @@ public class inputHandler { } while(keyReleaseBufferIndex < theCounter){ char c = keyReleaseBuffer[keyReleaseBufferIndex]; + if(c == 's' || c == 'S'){ S_pressed = false; } @@ -170,6 +174,7 @@ public class inputHandler { } + //handle input when game is running if(!mainThread.gamePaused && mainThread.gameStarted){ camera.MOVE_LEFT = false; @@ -366,7 +371,6 @@ public class inputHandler { mainThread.AIVictory = false; mainThread.playerVictory = false; mainThread.afterMatch = false; - mainThread.fogOfWarDisabled = false; mainThread.theAssetManager.destoryAsset(); camera.MOVE_LEFT = false; @@ -382,7 +386,7 @@ public class inputHandler { mainThread.playerVictory = false; mainThread.afterMatch = true; mainThread.gamePaused = false; - mainThread.fogOfWarDisabled = true; + } //toggle mouse capture mode @@ -423,6 +427,8 @@ public class inputHandler { inputCounter++; if(inputCounter == 1024) inputCounter = 0; + + } public static void handleKeyRelease(char c){