This commit is contained in:
Pan 2019-05-25 19:47:21 +12:00
parent 4b66ded27c
commit b9cadc4863
9 changed files with 292 additions and 139 deletions

View File

@ -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); //harvester l = new harvester(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0);
//addHarvester(l); //addHarvester(l);
//l.hasMultiShotUpgrade = true; //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; //l.attackRange = 1.99f;
//lightTank.tileCheckList_player = lightTank.generateTileCheckList(6); //lightTank.tileCheckList_player = lightTank.generateTileCheckList(6);
addLightTank(l); //addLightTank(l);
//if(j == 0 && i == 0) //if(j == 0 && i == 0)
//addMissileTurret(new missileTurret(i*0.25f -0.125f + 1, -0.65f, 0.25f + 17.125f + j*0.25f, 0)); //addMissileTurret(new missileTurret(i*0.25f -0.125f + 1, -0.65f, 0.25f + 17.125f + j*0.25f, 0));

View File

@ -14,13 +14,17 @@ public class highscoreManager implements Runnable{
public int task; public int task;
public static final int none = 0; public static final int none = 0;
public static final int loadHighscores = 1; public static final int loadHighscores = 1;
public static final int uploadScore = 2;
public boolean isSleeping; public boolean isSleeping;
public String playerName;
public String[][] result; public String[][] result;
public highscoreManager(){ public highscoreManager(){
status = processing; status = processing;
playerName = "";
} }
@ -57,7 +61,7 @@ public class highscoreManager implements Runnable{
stmt = connect.createStatement(); stmt = connect.createStatement();
ResultSet rs=stmt.executeQuery("select * from highscore where skillLevel = 0 order by finishingTime"); ResultSet rs=stmt.executeQuery("select * from highscore where skillLevel = 0 order by finishingTime");
while(rs.next()) { while(rs.next()) {
String playerName = rs.getString(1); playerName = rs.getString(1);
if(!hasDuplicateName(0, numOfRows, myResult, playerName)) { if(!hasDuplicateName(0, numOfRows, myResult, playerName)) {
myResult[numOfRows][0] = playerName; myResult[numOfRows][0] = playerName;
@ -72,7 +76,7 @@ public class highscoreManager implements Runnable{
numOfRows = 10; numOfRows = 10;
rs=stmt.executeQuery("select * from highscore where skillLevel = 1 order by finishingTime"); rs=stmt.executeQuery("select * from highscore where skillLevel = 1 order by finishingTime");
while(rs.next()) { while(rs.next()) {
String playerName = rs.getString(1); playerName = rs.getString(1);
if(!hasDuplicateName(10, numOfRows, myResult, playerName)) { if(!hasDuplicateName(10, numOfRows, myResult, playerName)) {
myResult[numOfRows][0] = rs.getString(1); myResult[numOfRows][0] = rs.getString(1);
myResult[numOfRows][1] = secondsToString(rs.getInt(2)); myResult[numOfRows][1] = secondsToString(rs.getInt(2));
@ -86,7 +90,7 @@ public class highscoreManager implements Runnable{
numOfRows = 20; numOfRows = 20;
rs=stmt.executeQuery("select * from highscore where skillLevel = 2 order by finishingTime"); rs=stmt.executeQuery("select * from highscore where skillLevel = 2 order by finishingTime");
while(rs.next()) { while(rs.next()) {
String playerName = rs.getString(1); playerName = rs.getString(1);
if(!hasDuplicateName(20, numOfRows, myResult, playerName)) { if(!hasDuplicateName(20, numOfRows, myResult, playerName)) {
myResult[numOfRows][0] = rs.getString(1); myResult[numOfRows][0] = rs.getString(1);
myResult[numOfRows][1] = secondsToString(rs.getInt(2)); myResult[numOfRows][1] = secondsToString(rs.getInt(2));
@ -98,13 +102,35 @@ public class highscoreManager implements Runnable{
} }
result = myResult; result = myResult;
playerName ="";
} catch (SQLException e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
status = error; status = error;
result = null; 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) if(status != error)

View File

@ -66,6 +66,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
public static boolean capturedMouse, mouseLeftScreen, focusLost; public static boolean capturedMouse, mouseLeftScreen, focusLost;
public static int mouseX, mouseY, centerScreenX, centerScreenY, currentMouseX, currentMouseY; public static int mouseX, mouseY, centerScreenX, centerScreenY, currentMouseX, currentMouseY;
public static char currentInputChar;
public mainThread(){ public mainThread(){
setTitle("Battle Tank 3"); setTitle("Battle Tank 3");

View File

@ -75,7 +75,7 @@ public class postProcessingThread implements Runnable{
public static textRenderer theTextRenderer; 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 int mouse_x, mouse_y;
public static boolean leftMouseButtonReleased, escapeKeyPressed; public static boolean leftMouseButtonReleased, escapeKeyPressed;
@ -85,6 +85,8 @@ public class postProcessingThread implements Runnable{
public static boolean fogOfWarDisabled; public static boolean fogOfWarDisabled;
public static boolean capturedMouse; public static boolean capturedMouse;
public static char currentInputChar;
//A pool of vectors which will be used for vector arithmetic //A pool of vectors which will be used for vector arithmetic
public static vector public static vector
tempVector1 = new vector(0,0,0), tempVector1 = new vector(0,0,0),
@ -561,123 +563,125 @@ public class postProcessingThread implements Runnable{
//reset fogOfWarBuffer //reset fogOfWarBuffer
fogOfWarBuffer[0] = 0; if(!afterMatch) {
for(int i = 1; i < 393216; i+=i){ fogOfWarBuffer[0] = 0;
System.arraycopy(fogOfWarBuffer, 0, fogOfWarBuffer, i, 393216 - i >= i ? i : 393216 - i); 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);
} }
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); fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit);
} index++;
} destIndex-=512;
destIndex = 0; for(int j = 1; j < radius; j++, index++, destIndex -=512){
index = 0; temp = temp + fogOfWarBuffer[index + radius -2] - 43;
for(int i = 0; i < 768; i++){ fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit);
//init the first element in the row }
temp = 0;
destIndex = 767 - i; for(int j = radius; j < 768 - radius; j++, index++, destIndex -=512){
temp = temp + fogOfWarBuffer[index + radius -2] - fogOfWarBuffer[index - radius];
for(int j = 0; j < radius -1 ; j++){ fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit);
temp+=fogOfWarBuffer2[index + j];
} }
temp+=43*radius; for(int j = 0; j < radius; j++, index++, destIndex -=512){
fogOfWarBuffer[destIndex] = (byte)(temp >> radiusBit); temp = temp - fogOfWarBuffer[index - radius] + 43;
index++; fogOfWarBuffer2[destIndex] = (byte)(temp >> radiusBit);
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){ destIndex = 0;
temp = temp + fogOfWarBuffer2[index + radius -2] - fogOfWarBuffer2[index - radius]; 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); 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;
//blend fog of war to the frame buffer g = (((currentScreen[i] & 0xff00) >> 8) * (temp + 143)) >> 8 ;
for(int i = 0; i < 512 * 768; i++){ b = ((currentScreen[i] & 0xff) * (temp + 143)) >> 8;
temp = fogOfWarBuffer[i]; currentScreen[i] = r << 16 | g << 8 | b;
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; gameStarted = mainThread.gameStarted;
playerVictory = mainThread.playerVictory; playerVictory = mainThread.playerVictory;
AIVictory = mainThread.AIVictory; AIVictory = mainThread.AIVictory;
afterMatch = mainThread.afterMatch;
timeString = mainThread.timeString; timeString = mainThread.timeString;
fogOfWarDisabled = mainThread.fogOfWarDisabled; fogOfWarDisabled = mainThread.fogOfWarDisabled;
capturedMouse = mainThread.capturedMouse; capturedMouse = mainThread.capturedMouse;
currentInputChar = mainThread.currentInputChar;
currentScreen = mainThread.screen; currentScreen = mainThread.screen;

View File

@ -426,7 +426,7 @@ public class stealthTank extends solidObject{
if(isCloaked){ if(isCloaked){
if(teamNo != 0){ if(teamNo != 0){
if(!mainThread.fogOfWarDisabled) if(!mainThread.fogOfWarDisabled && !mainThread.afterMatch)
if(currentCloakingStatus < 127) if(currentCloakingStatus < 127)
currentCloakingStatus+=3; currentCloakingStatus+=3;
}else{ }else{
@ -556,10 +556,10 @@ public class stealthTank extends solidObject{
} }
//check if the tank object is visible in mini map //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(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 = theAssetManager.unitsForMiniMap[theAssetManager.unitsForMiniMapCount];
tempInt[0] = teamNo + (this.type << 8); tempInt[0] = teamNo + (this.type << 8);
tempInt[1] = boundary2D.x1/16; tempInt[1] = boundary2D.x1/16;

View File

@ -61,7 +61,7 @@ public class MiniMap {
drawBackground(screen, minimapBitmap); drawBackground(screen, minimapBitmap);
//remove fog of war for testing //remove fog of war for testing
if(postProcessingThread.fogOfWarDisabled) if(postProcessingThread.fogOfWarDisabled || postProcessingThread.afterMatch)
for(int i = 0; i < minimapBitmap.length; i++) for(int i = 0; i < minimapBitmap.length; i++)
minimapBitmap[i] = true; minimapBitmap[i] = true;
@ -304,6 +304,9 @@ public class MiniMap {
for(int i = 0 ;i < tempBitmap.length; i++){ for(int i = 0 ;i < tempBitmap.length; i++){
tempBitmap[i] = false; tempBitmap[i] = false;
if(postProcessingThread.afterMatch)
tempBitmap[i] = true;
} }
boolean[] vision; boolean[] vision;
@ -354,7 +357,6 @@ public class MiniMap {
} }
for(int y = 0; y < 128; y++){ for(int y = 0; y < 128; y++){
for(int x = 0; x < 128; x++){ for(int x = 0; x < 128; x++){
minimapBitmap[x + y*128] = tempBitmap[x + 10 + (y + 10)*148]; minimapBitmap[x + y*128] = tempBitmap[x + 10 + (y + 10)*148];

View File

@ -11,6 +11,7 @@ public class button {
public int actionCooldown; public int actionCooldown;
public int red, green, blue; public int red, green, blue;
public boolean disabled; public boolean disabled;
public boolean messageMode;
public button(String name, String text, int xPos, int yPos, int width, int height) { public button(String name, String text, int xPos, int yPos, int width, int height) {
this.name = name; this.name = name;
@ -30,7 +31,7 @@ public class button {
} }
public void draw(int[] screen) { public void draw(int[] screen) {
if(disabled) { if(disabled && !messageMode) {
red = 55; red = 55;
green = 55; green = 55;
blue = 55; blue = 55;

View File

@ -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, 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, 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; public char[] easyDescription, normalDescription, hardDescription, helpPage1, helpPage2, helpPage3, helpPage4, mouseMode;
@ -38,6 +38,11 @@ public class gameMenu {
public highscoreManager theHighscoreManager; public highscoreManager theHighscoreManager;
public char[] name;
public String nameString;
public static boolean uploadingScore, scoreUploaded;
public void init() { public void init() {
if(titleImage == null) { if(titleImage == null) {
titleImage = new int[288*46]; titleImage = new int[288*46];
@ -54,6 +59,9 @@ public class gameMenu {
t.start(); t.start();
highscoreLevel = 1; highscoreLevel = 1;
name = new char[32];
for(int i = 0; i< 32; i++)
name[i] = 255;
String folder = "../images/"; String folder = "../images/";
loadTexture(folder + "title.png", titleImage, 216, 35); loadTexture(folder + "title.png", titleImage, 216, 35);
@ -191,12 +199,21 @@ public class gameMenu {
leaveGameDefeat = new button("abortGame", "Leave game", 440, 235, 120, 25); leaveGameDefeat = new button("abortGame", "Leave game", 440, 235, 120, 25);
buttons.add(leaveGameDefeat); 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) { public void updateAndDraw(int[] screen, boolean gameStarted, boolean gamePaused, boolean playerVictory, boolean AIVictory) {
this.screen = screen; this.screen = screen;
textRenderer tRenderer = postProcessingThread.theTextRenderer;
if(gamePaused){ if(gamePaused){
gameSuspendCount++; gameSuspendCount++;
@ -226,11 +243,103 @@ public class gameMenu {
if(AIVictory) { if(AIVictory) {
drawMenuFrame(400, 100, 70); 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; backToMapDefeat.display = true;
leaveGameDefeat.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(); updateButtons();
@ -277,8 +386,7 @@ public class gameMenu {
}else { }else {
drawTitle(); drawTitle();
drawMenuFrame(420, 260); drawMenuFrame(420, 260);
textRenderer tRenderer = postProcessingThread.theTextRenderer;
easyGame.display = true; easyGame.display = true;
tRenderer.drawMenuText(285,118,easyDescription, screen, 255,255,255, 0); tRenderer.drawMenuText(285,118,easyDescription, screen, 255,255,255, 0);
@ -304,8 +412,6 @@ public class gameMenu {
drawTitle(); drawTitle();
drawMenuFrame(620, 380); drawMenuFrame(620, 380);
textRenderer tRenderer = postProcessingThread.theTextRenderer;
if(currentHelpPage == 0) { if(currentHelpPage == 0) {
tRenderer.drawMenuText(82,90,helpPage1, screen, 255,255,255,0); tRenderer.drawMenuText(82,90,helpPage1, screen, 255,255,255,0);
nextPage.display = true; nextPage.display = true;
@ -342,7 +448,6 @@ public class gameMenu {
drawTitle(); drawTitle();
drawMenuFrame(520, 380); drawMenuFrame(520, 380);
textRenderer tRenderer = postProcessingThread.theTextRenderer;
tRenderer.drawMenuText(135,95,mouseMode, screen, 255,255,255,0); tRenderer.drawMenuText(135,95,mouseMode, screen, 255,255,255,0);
if(postProcessingThread.capturedMouse == true) { if(postProcessingThread.capturedMouse == true) {
@ -384,8 +489,6 @@ public class gameMenu {
drawTitle(); drawTitle();
drawMenuFrame(420, 360); drawMenuFrame(420, 360);
textRenderer tRenderer = postProcessingThread.theTextRenderer;
if(theHighscoreManager.status == theHighscoreManager.processing) { if(theHighscoreManager.status == theHighscoreManager.processing) {
drawLoadingScreen(screen); drawLoadingScreen(screen);
}else if(theHighscoreManager.status == theHighscoreManager.idle) { }else if(theHighscoreManager.status == theHighscoreManager.idle) {
@ -522,6 +625,15 @@ public class gameMenu {
highscoreLevel = 0; highscoreLevel = 0;
}else if(buttons.get(i).name == "abortGame") { }else if(buttons.get(i).name == "abortGame") {
menuStatus = mainMenu; 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; postProcessingThread.buttonAction = buttons.get(i).name;

View File

@ -51,11 +51,13 @@ public class inputHandler {
//read input char //read input char
int theCounter = inputCounter; int theCounter = inputCounter;
mainThread.currentInputChar = 255;
//handle over flow //handle over flow
if(inputBufferIndex > theCounter){ if(inputBufferIndex > theCounter){
while(inputBufferIndex < 1024){ while(inputBufferIndex < 1024){
char c = inputBuffer[inputBufferIndex]; char c = inputBuffer[inputBufferIndex];
mainThread.currentInputChar = c;
if(c == 's' || c == 'S'){ if(c == 's' || c == 'S'){
@ -91,7 +93,7 @@ public class inputHandler {
while(inputBufferIndex < theCounter){ while(inputBufferIndex < theCounter){
char c = inputBuffer[inputBufferIndex]; char c = inputBuffer[inputBufferIndex];
mainThread.currentInputChar = c;
if(c == 's' || c == 'S'){ if(c == 's' || c == 'S'){
S_pressed = true; S_pressed = true;
@ -124,6 +126,7 @@ public class inputHandler {
if(keyReleaseBufferIndex > theCounter){ if(keyReleaseBufferIndex > theCounter){
while(keyReleaseBufferIndex < 1024){ while(keyReleaseBufferIndex < 1024){
char c = keyReleaseBuffer[keyReleaseBufferIndex]; char c = keyReleaseBuffer[keyReleaseBufferIndex];
if(c == 's' || c == 'S'){ if(c == 's' || c == 'S'){
S_pressed = false; S_pressed = false;
} }
@ -148,6 +151,7 @@ public class inputHandler {
} }
while(keyReleaseBufferIndex < theCounter){ while(keyReleaseBufferIndex < theCounter){
char c = keyReleaseBuffer[keyReleaseBufferIndex]; char c = keyReleaseBuffer[keyReleaseBufferIndex];
if(c == 's' || c == 'S'){ if(c == 's' || c == 'S'){
S_pressed = false; S_pressed = false;
} }
@ -170,6 +174,7 @@ public class inputHandler {
} }
//handle input when game is running //handle input when game is running
if(!mainThread.gamePaused && mainThread.gameStarted){ if(!mainThread.gamePaused && mainThread.gameStarted){
camera.MOVE_LEFT = false; camera.MOVE_LEFT = false;
@ -366,7 +371,6 @@ public class inputHandler {
mainThread.AIVictory = false; mainThread.AIVictory = false;
mainThread.playerVictory = false; mainThread.playerVictory = false;
mainThread.afterMatch = false; mainThread.afterMatch = false;
mainThread.fogOfWarDisabled = false;
mainThread.theAssetManager.destoryAsset(); mainThread.theAssetManager.destoryAsset();
camera.MOVE_LEFT = false; camera.MOVE_LEFT = false;
@ -382,7 +386,7 @@ public class inputHandler {
mainThread.playerVictory = false; mainThread.playerVictory = false;
mainThread.afterMatch = true; mainThread.afterMatch = true;
mainThread.gamePaused = false; mainThread.gamePaused = false;
mainThread.fogOfWarDisabled = true;
} }
//toggle mouse capture mode //toggle mouse capture mode
@ -423,6 +427,8 @@ public class inputHandler {
inputCounter++; inputCounter++;
if(inputCounter == 1024) if(inputCounter == 1024)
inputCounter = 0; inputCounter = 0;
} }
public static void handleKeyRelease(char c){ public static void handleKeyRelease(char c){