home commit

This commit is contained in:
Pan 2019-03-21 10:28:34 +13:00
parent 7a3ff77530
commit a327f66010
11 changed files with 751 additions and 713 deletions

View File

@ -71,48 +71,6 @@ public class AssetManager {
public void init(){
selectedUnitsInfo = new int[100][6];
selectedUnitsInfo2 = new int[100][6];
visionPolygonInfo = new float[400][5];
visionPolygonInfo2 = new float[400][5];
unitsForMiniMap = new int[1000][5];
unitsForMiniMap2 = new int[1000][5];
smokeEmmiterList = new float[100][8];
smokeEmmiterList2 = new float[100][8];
minimapBitmap = new boolean[128 * 128];
minimapBitmap2 = new boolean[128 * 128];
explosionInfo = new float[100][8];
explosionInfo2 = new float[100][8];
helixInfo = new float[128][4];
helixInfo2 = new float[128][4];
confirmationIconInfo = new double[5];
confirmationIconInfo2 = new double[5];
bullets = new bullet[200];
for(int i = 0; i < 200; i ++){
bullets[i] = new bullet();
}
rockets = new rocket[200];
for(int i = 0; i < 200; i ++){
rockets[i] = new rocket();
}
visibleUnit = new solidObject[400];
//polygons which represent the area of sight for player
double angle = Math.PI/24;
visionPolygon = new polygon3D[4];
@ -143,55 +101,9 @@ public class AssetManager {
}
visionPolygon[3] = new polygon3D(v, v[0], v[1], v[3], null, 1,1, 2);
lightTanks = new lightTank[768];
heavyTanks = new heavyTank[256];
trees = new palmTree[2048];
powerPlants = new powerPlant[256];
refineries = new refinery[128];
rocketTanks = new rocketTank[512];
harvesters = new harvester[128];
constructionVehicles = new constructionVehicle[64];
goldMines = new goldMine[16];
constructionYards = new constructionYard[64];
factories = new factory[128];
drones = new drone[384];
communicationCenters = new communicationCenter[128];
techCenters = new techCenter[64];
stealthTanks = new stealthTank[384];
gunTurrets = new gunTurret[512];
missileTurrets = new missileTurret[256];
Terrain = new terrain();
//unit costs/hit point/power consumption/exp on kill
//lightTank 300/120/0/10
//rocketTank 450/70/0/15
//harvester 800/260/0/25
//stealth tank 600/80/0/20
//heavyTank 1100/320/0/50
//constructionVehicle 1700/300/0/30
//
//power plant 500/400/+500/25
//refinery 1200/750/-150/35
//communication center 1000/550/-250/35
//factory 1400/850/-200/40
//tech center 1500/s/-450/50
//gun turret 400/250/-100/20
//missile turret 750/250/(-200/-400)/35
//construction yard 1700/1000/0/50
//
//harvester speed research 1200
//missile turret overcharge research 1500
//light tank range upgrade 1500
//Missile tank dmg upgrade 2500
//stealth tank split lasor 2500
//Heavy tank regen 3000
goldMines = new goldMine[16];
goldMines[0] = new goldMine(2f,-0.515f, 1.25f, 45000);
goldMines[1] = new goldMine(9.5f,-0.515f, 5.5f, 45000);
goldMines[2] = new goldMine(2f,-0.515f, 28.25f, 50000);
@ -203,6 +115,7 @@ public class AssetManager {
//create trees from bitmap
trees = new palmTree[2048];
short[] treeBitmap = mainThread.textures[56].pixelData;
for(int i = 0; i < 114; i++){
for(int j = 0; j < 114; j++){
@ -214,20 +127,88 @@ public class AssetManager {
}
}
visibleUnit = new solidObject[400];
mainThread.pc = new playerCommander();
mainThread.pc.init();
mainThread.ec = new enemyCommander();
mainThread.ec.init();
}
public void prepareAssetForNewGame(){
selectedUnitsInfo = new int[100][6];
selectedUnitsInfo2 = new int[100][6];
visionPolygonInfo = new float[400][5];
visionPolygonInfo2 = new float[400][5];
unitsForMiniMap = new int[1000][5];
unitsForMiniMap2 = new int[1000][5];
smokeEmmiterList = new float[100][8];
smokeEmmiterList2 = new float[100][8];
minimapBitmap = new boolean[128 * 128];
minimapBitmap2 = new boolean[128 * 128];
explosionInfo = new float[100][8];
explosionInfo2 = new float[100][8];
helixInfo = new float[128][4];
helixInfo2 = new float[128][4];
confirmationIconInfo = new double[5];
confirmationIconInfo2 = new double[5];
lightTanks = new lightTank[768];
heavyTanks = new heavyTank[256];
powerPlants = new powerPlant[256];
refineries = new refinery[128];
rocketTanks = new rocketTank[512];
harvesters = new harvester[128];
constructionVehicles = new constructionVehicle[64];
constructionYards = new constructionYard[64];
factories = new factory[128];
drones = new drone[384];
communicationCenters = new communicationCenter[128];
techCenters = new techCenter[64];
stealthTanks = new stealthTank[384];
gunTurrets = new gunTurret[512];
missileTurrets = new missileTurret[256];
goldMines[0].goldDeposite = 45000;
goldMines[1].goldDeposite = 45000;
goldMines[2].goldDeposite = 50000;
goldMines[3].goldDeposite = 50000;
goldMines[4].goldDeposite = 45000;
goldMines[5].goldDeposite = 45000;
goldMines[6].goldDeposite = 55000;
goldMines[7].goldDeposite = 55000;
bullets = new bullet[200];
for(int i = 0; i < 200; i ++){
bullets[i] = new bullet();
}
rockets = new rocket[200];
for(int i = 0; i < 200; i ++){
rockets[i] = new rocket();
}
mainThread.pc.init();
mainThread.ec.init();
addConstructionVehicle(new constructionVehicle(new vector(3.125f,-0.3f, 2.125f), 90, 0));
addConstructionVehicle(new constructionVehicle(new vector(29.625f,-0.3f, 28.875f), 90, 1));
constructionVehicles[1].expand();
//testing only
for(int i = 0; i < 6; i ++){
for(int j = 0; j < 10; j++){
@ -417,235 +398,241 @@ public class AssetManager {
helixCount = 0;
Terrain.update();
for(int i = 0; i < lightTanks.length; i++){
if(lightTanks[i] != null)
lightTanks[i].update();
}
for(int i = 0; i < heavyTanks.length; i++){
if(heavyTanks[i] != null)
heavyTanks[i].update();
}
for(int i = 0; i < stealthTanks.length; i++){
if(stealthTanks[i] != null)
stealthTanks[i].update();
if(mainThread.gameStarted) {
for(int i = 0; i < lightTanks.length; i++){
if(lightTanks[i] != null)
lightTanks[i].update();
}
for(int i = 0; i < heavyTanks.length; i++){
if(heavyTanks[i] != null)
heavyTanks[i].update();
}
for(int i = 0; i < stealthTanks.length; i++){
if(stealthTanks[i] != null)
stealthTanks[i].update();
}
for(int i = 0; i < constructionYards.length; i++){
if(constructionYards[i] != null)
constructionYards[i].update();
}
for(int i = 0; i < powerPlants.length; i++){
if(powerPlants[i] != null)
powerPlants[i].update();
}
for(int i = 0; i < techCenters.length; i++){
if(techCenters[i] != null)
techCenters[i].update();
}
for(int i = 0; i < gunTurrets.length; i++){
if(gunTurrets[i] != null)
gunTurrets[i].update();
}
for(int i = 0; i < missileTurrets.length; i++){
if(missileTurrets[i] != null)
missileTurrets[i].update();
}
for(int i = 0; i < communicationCenters.length; i++){
if(communicationCenters[i] != null)
communicationCenters[i].update();
}
for(int i = 0; i < refineries.length; i++){
if(refineries[i] != null)
refineries[i].update();
}
for(int i = 0; i < factories.length; i++){
if(factories[i] != null)
factories[i].update();
}
for(int i = 0; i < drones.length; i++){
if(drones[i] != null)
drones[i].update();
}
for(int i = 0; i < rocketTanks.length; i++){
if(rocketTanks[i] != null)
rocketTanks[i].update();
}
for(int i = 0; i < harvesters.length; i++){
if(harvesters[i] != null)
harvesters[i].update();
}
for(int i = 0; i < constructionVehicles.length; i++){
if(constructionVehicles[i] != null)
constructionVehicles[i].update();
}
}
for(int i = 0; i < plamTreeCount; i++)
trees[i].update();
for(int i = 0; i < constructionYards.length; i++){
if(constructionYards[i] != null)
constructionYards[i].update();
}
for(int i = 0; i < powerPlants.length; i++){
if(powerPlants[i] != null)
powerPlants[i].update();
}
for(int i = 0; i < techCenters.length; i++){
if(techCenters[i] != null)
techCenters[i].update();
}
for(int i = 0; i < gunTurrets.length; i++){
if(gunTurrets[i] != null)
gunTurrets[i].update();
}
for(int i = 0; i < missileTurrets.length; i++){
if(missileTurrets[i] != null)
missileTurrets[i].update();
}
for(int i = 0; i < communicationCenters.length; i++){
if(communicationCenters[i] != null)
communicationCenters[i].update();
}
for(int i = 0; i < refineries.length; i++){
if(refineries[i] != null)
refineries[i].update();
}
for(int i = 0; i < factories.length; i++){
if(factories[i] != null)
factories[i].update();
}
for(int i = 0; i < drones.length; i++){
if(drones[i] != null)
drones[i].update();
}
for(int i = 0; i < rocketTanks.length; i++){
if(rocketTanks[i] != null)
rocketTanks[i].update();
}
for(int i = 0; i < harvesters.length; i++){
if(harvesters[i] != null)
harvesters[i].update();
}
for(int i = 0; i < constructionVehicles.length; i++){
if(constructionVehicles[i] != null)
constructionVehicles[i].update();
}
for(int i = 0; i < 10; i++){
if(goldMines[i] != null)
goldMines[i].update();
}
Terrain.update();
//start drawing
//maximize the zbuffer value in the area that are occupied by UI, so the drawing process will not waste time filling the pixels which would eventually get overdrawn
/*int start = 381 * 768 + 3;
int start2 = 381 * 768 + 635;
for(int y = 0; y < 131; y++){
for(int x = 0; x < 128; x ++){
mainThread.zBuffer[start + x + y*768] = Integer.MAX_VALUE;
mainThread.zBuffer[start2 + x + y*768] = Integer.MAX_VALUE;
if(mainThread.gameStarted) {
int start = 381 * 768 + 3;
int start2 = 381 * 768 + 635;
for(int y = 0; y < 131; y++){
for(int x = 0; x < 128; x ++){
mainThread.zBuffer[start + x + y*768] = Integer.MAX_VALUE;
mainThread.zBuffer[start2 + x + y*768] = Integer.MAX_VALUE;
}
}
}*/
for(int i = 0; i < 200; i ++)
bullets[i].updateAndDraw();
for(int i = 0; i < 200; i ++)
rockets[i].update();
for(int i = 0; i < lightTanks.length; i++){
if(lightTanks[i] != null)
lightTanks[i].draw();
for(int i = 0; i < 200; i ++)
bullets[i].updateAndDraw();
for(int i = 0; i < 200; i ++)
rockets[i].update();
for(int i = 0; i < lightTanks.length; i++){
if(lightTanks[i] != null)
lightTanks[i].draw();
}
for(int i = 0; i < heavyTanks.length; i++){
if(heavyTanks[i] != null)
heavyTanks[i].draw();
}
for(int i = 0; i < stealthTanks.length; i++){
if(stealthTanks[i] != null)
stealthTanks[i].draw();
}
for(int i = 0; i < powerPlants.length; i++){
if(powerPlants[i] != null)
powerPlants[i].draw();
}
for(int i = 0; i < gunTurrets.length; i++){
if(gunTurrets[i] != null)
gunTurrets[i].draw();
}
for(int i = 0; i < missileTurrets.length; i++){
if(missileTurrets[i] != null)
missileTurrets[i].draw();
}
for(int i = 0; i < communicationCenters.length; i++){
if(communicationCenters[i] != null)
communicationCenters[i].draw();
}
for(int i = 0; i < techCenters.length; i++){
if(techCenters[i] != null)
techCenters[i].draw();
}
for(int i = 0; i < refineries.length; i++){
if(refineries[i] != null)
refineries[i].draw();
}
for(int i = 0; i < rocketTanks.length; i++){
if(rocketTanks[i] != null)
rocketTanks[i].draw();
}
for(int i = 0; i < harvesters.length; i++){
if(harvesters[i] != null)
harvesters[i].draw();
}
for(int i = 0; i < constructionVehicles.length; i++){
if(constructionVehicles[i] != null)
constructionVehicles[i].draw();
}
for(int i = 0; i < constructionYards.length; i++){
if(constructionYards[i] != null)
constructionYards[i].draw();
}
for(int i = 0; i < 200; i ++)
rockets[i].draw();
for(int i = 0; i < drones.length; i++){
if(drones[i] != null)
drones[i].draw();
}
for(int i = 0; i < factories.length; i++){
if(factories[i] != null)
factories[i].draw();
}
}
for(int i = 0; i < heavyTanks.length; i++){
if(heavyTanks[i] != null)
heavyTanks[i].draw();
}
for(int i = 0; i < stealthTanks.length; i++){
if(stealthTanks[i] != null)
stealthTanks[i].draw();
}
for(int i = 0; i < plamTreeCount; i++)
trees[i].draw();
for(int i = 0; i < powerPlants.length; i++){
if(powerPlants[i] != null)
powerPlants[i].draw();
}
for(int i = 0; i < gunTurrets.length; i++){
if(gunTurrets[i] != null)
gunTurrets[i].draw();
}
for(int i = 0; i < missileTurrets.length; i++){
if(missileTurrets[i] != null)
missileTurrets[i].draw();
}
for(int i = 0; i < communicationCenters.length; i++){
if(communicationCenters[i] != null)
communicationCenters[i].draw();
}
for(int i = 0; i < techCenters.length; i++){
if(techCenters[i] != null)
techCenters[i].draw();
}
for(int i = 0; i < refineries.length; i++){
if(refineries[i] != null)
refineries[i].draw();
}
for(int i = 0; i < rocketTanks.length; i++){
if(rocketTanks[i] != null)
rocketTanks[i].draw();
}
for(int i = 0; i < harvesters.length; i++){
if(harvesters[i] != null)
harvesters[i].draw();
}
for(int i = 0; i < constructionVehicles.length; i++){
if(constructionVehicles[i] != null)
constructionVehicles[i].draw();
}
for(int i = 0; i < constructionYards.length; i++){
if(constructionYards[i] != null)
constructionYards[i].draw();
}
for(int i = 0; i < goldMines.length; i++){
if(goldMines[i] != null)
goldMines[i].draw();
}
for(int i = 0; i < 200; i ++)
rockets[i].draw();
for(int i = 0; i < drones.length; i++){
if(drones[i] != null)
drones[i].draw();
}
for(int i = 0; i < factories.length; i++){
if(factories[i] != null)
factories[i].draw();
}
for(int i = 0; i < plamTreeCount; i++)
trees[i].draw();
Terrain.draw();
if(mainThread.pc.selectedConstructionYard != null){
mainThread.pc.selectedConstructionYard.drawDeploymentGrid();
}
for(int i = 0; i < factories.length; i++){
if(factories[i] != null)
factories[i].drawRallyPointLine();
}
//prepare selected unit list
for(int i = 0; i < 99; i++){
if(mainThread.pc.selectedUnits[i] != null && mainThread.pc.selectedUnits[i].isSelectable){
selectedUnitsInfo[i][0] = mainThread.pc.selectedUnits[i].level << 16 | mainThread.pc.selectedUnits[i].groupNo << 8 | mainThread.pc.selectedUnits[i].type;
selectedUnitsInfo[i][1] = (int)mainThread.pc.selectedUnits[i].tempCentre.screenX;
selectedUnitsInfo[i][2] = (int)mainThread.pc.selectedUnits[i].tempCentre.screenY;
if(mainThread.pc.selectedUnits[i].type == 199){
selectedUnitsInfo[i][1] = (int)mainThread.pc.selectedUnits[i].screenX_gui;
selectedUnitsInfo[i][2] = (int)mainThread.pc.selectedUnits[i].screenY_gui;
if(mainThread.gameStarted) {
if(mainThread.pc.selectedConstructionYard != null){
mainThread.pc.selectedConstructionYard.drawDeploymentGrid();
}
for(int i = 0; i < factories.length; i++){
if(factories[i] != null)
factories[i].drawRallyPointLine();
}
//prepare selected unit list
for(int i = 0; i < 99; i++){
if(mainThread.pc.selectedUnits[i] != null && mainThread.pc.selectedUnits[i].isSelectable){
selectedUnitsInfo[i][0] = mainThread.pc.selectedUnits[i].level << 16 | mainThread.pc.selectedUnits[i].groupNo << 8 | mainThread.pc.selectedUnits[i].type;
selectedUnitsInfo[i][1] = (int)mainThread.pc.selectedUnits[i].tempCentre.screenX;
selectedUnitsInfo[i][2] = (int)mainThread.pc.selectedUnits[i].tempCentre.screenY;
if(mainThread.pc.selectedUnits[i].type == 199){
selectedUnitsInfo[i][1] = (int)mainThread.pc.selectedUnits[i].screenX_gui;
selectedUnitsInfo[i][2] = (int)mainThread.pc.selectedUnits[i].screenY_gui;
}
selectedUnitsInfo[i][3] = (int)mainThread.pc.selectedUnits[i].type;
selectedUnitsInfo[i][4] = mainThread.pc.selectedUnits[i].currentHP;
selectedUnitsInfo[i][5] = mainThread.pc.selectedUnits[i].progressStatus;
}else{
selectedUnitsInfo[i][0] = -1;
}
selectedUnitsInfo[i][3] = (int)mainThread.pc.selectedUnits[i].type;
selectedUnitsInfo[i][4] = mainThread.pc.selectedUnits[i].currentHP;
selectedUnitsInfo[i][5] = mainThread.pc.selectedUnits[i].progressStatus;
}else{
selectedUnitsInfo[i][0] = -1;
}
}

View File

@ -21,6 +21,8 @@ public class camera{
//a rectangle that represents the screen area
public static final Rectangle screen = new Rectangle(0,0,768, 512);
public static vector cameraMovement;
public camera(vector p, int XZ, int YZ){
view_Direction = new vector(0, 0, 1);
@ -35,6 +37,26 @@ public class camera{
}
public void update(){
if(!mainThread.gameStarted) {
//when game has not started, use a "fly through" as the background for the menu
if(mainThread.frameIndex == 1) {
mainThread.Camera.position.z = 2.5f;
mainThread.Camera.position.x = 9;
cameraMovement = new vector(-0.01f,0,0);
}
if(mainThread.frameIndex > 90 && mainThread.frameIndex%400 >= 0 && mainThread.frameIndex%400 < 90) {
XZ_angle+=1;
cameraMovement.rotate_XZ(359);
}
position.add(cameraMovement);
}
position.add(view_Direction.x*3, 0 , view_Direction.z*3);
@ -77,7 +99,7 @@ public class camera{
down.unit();
position.add(down, -0.1f);
}
//make sure the camera never leaves the map
if(position.x < 0.5){
position.x = 0.5f;
@ -126,9 +148,6 @@ public class camera{
TURN_LEFT = false;
TURN_RIGHT = false;
}
}

View File

@ -30,7 +30,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
public static int framePerSecond, cpuUsage;
public static double thisTime, lastTime;
public static boolean JavaRTSLoaded;
public static boolean gamePaused, gameStarted;
public static boolean gamePaused, gameStarted, gameEnded;
public static texture[] textures;
public static byte[][] lightMapTextures;
public static int[][] lightMapTexturesInfo;
@ -52,7 +52,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
public mainThread(){
setTitle("JAVA RTS");
setTitle("Battle Tank 3");
panel= (JPanel) this.getContentPane();
panel.setPreferredSize(new Dimension(768, 512));
panel.setMinimumSize(new Dimension(768,512));
@ -65,79 +65,67 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//create screen buffer
doubleBuffer = new BufferedImage(768, 512, BufferedImage.TYPE_INT_RGB);
DataBuffer dest = doubleBuffer.getRaster().getDataBuffer();
screen = ((DataBufferInt)dest).getData();
//load resource if the applet is loaded for the first time. (i.e refresh browser will not cause the applet to load resources again)
if(JavaRTSLoaded == false){
//create screen buffer
doubleBuffer = new BufferedImage(768, 512, BufferedImage.TYPE_INT_RGB);
DataBuffer dest = doubleBuffer.getRaster().getDataBuffer();
screen = ((DataBufferInt)dest).getData();
doubleBuffer2 = new BufferedImage(768, 512, BufferedImage.TYPE_INT_RGB);
DataBuffer dest2 = doubleBuffer2.getRaster().getDataBuffer();
screen2 = ((DataBufferInt)dest2).getData();
//create depth buffer
zBuffer = new int[393216];
zBuffer2 = new int[393216];
//create shadoow bitmap
shadowBitmap = new byte[393216];
shadowBitmap2 = new byte[393216];
for(int i = 0; i < 393216; i++){
shadowBitmap[i] = 127;
shadowBitmap2[i] = 127;
}
//create displacement buffer
displacementBuffer = new short[393216];
displacementBuffer2 = new short[393216];
for(int i = 0; i < 393216; i++){
displacementBuffer[i] = 12345;
}
//create camera
Camera = new camera(new vector(3,2f,-1.25f), 0, 300);
doubleBuffer2 = new BufferedImage(768, 512, BufferedImage.TYPE_INT_RGB);
DataBuffer dest2 = doubleBuffer2.getRaster().getDataBuffer();
screen2 = ((DataBufferInt)dest2).getData();
//Create look up tables
gameData.makeData();
//init grid
gridMap = new grid(128);
//init light source
sunLight.init();
//init rasterizer
rasterizer.init();
//init 2d to 3d factory
my2Dto3DFactory = new Turn2DTo3DFactory();
my2Dto3DFactory.init();
loadTexture();
//init post processing thread
postProcessingThread.init();
theAssetManager = new AssetManager();
theAssetManager.init();
frameIndex = 0;
frameInterval = 33;
lastDraw = 0;
JavaRTSLoaded = true;
//test only
gamePaused = false;
//create depth buffer
zBuffer = new int[393216];
zBuffer2 = new int[393216];
//create shadoow bitmap
shadowBitmap = new byte[393216];
shadowBitmap2 = new byte[393216];
for(int i = 0; i < 393216; i++){
shadowBitmap[i] = 127;
shadowBitmap2[i] = 127;
}
//create displacement buffer
displacementBuffer = new short[393216];
displacementBuffer2 = new short[393216];
for(int i = 0; i < 393216; i++){
displacementBuffer[i] = 12345;
}
//create camera
Camera = new camera(new vector(3,2f,-1.25f), 0, 300);
//Create look up tables
gameData.makeData();
//init grid
gridMap = new grid(128);
//init light source
sunLight.init();
//init rasterizer
rasterizer.init();
//init 2d to 3d factory
my2Dto3DFactory = new Turn2DTo3DFactory();
my2Dto3DFactory.init();
loadTexture();
//init post processing thread
postProcessingThread.init();
theAssetManager = new AssetManager();
theAssetManager.init();
frameIndex = 0;
frameInterval = 33;
lastDraw = 0;
//Add key handler
panel.addKeyListener(this);
@ -160,6 +148,9 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
PPT = new postProcessingThread();
Thread theTread = new Thread(PPT);
//test only
gameStarted = false;
//start threads
t.start();
dt.start();
@ -179,13 +170,13 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
inputHandler.processInput();
//handle user's interaction with game GUI
if(frameIndex == 1){
theAssetManager.prepareAssetForNewGame();
}
if(!gamePaused) {
//handle user's interaction with game GUI
if(frameIndex == 1 && gameStarted){
theAssetManager.prepareAssetForNewGame();
}
gridMap.update();
//Clears the z-buffer. All depth values are set to 0.
@ -200,12 +191,16 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
//update and draw 3D mashes from game objects
theAssetManager.updateAndDraw();
pc.update();
ec.update();
if(gameStarted) {
pc.update();
ec.update();
}
}else {
}
//show inpassible obstacle
//show unpassable obstacle
//gridMap.draw();
if(this.getGraphics() != null && PPT!= null){
@ -486,7 +481,8 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
rasterizer.displacementBuffer = mainThread.displacementBuffer;
theAssetManager.swapResources();
pc.theSideBarManager.swapResources();
if(gameStarted)
pc.theSideBarManager.swapResources();
}

View File

@ -4,6 +4,7 @@ import entity.*;
import gui.MiniMap;
import gui.SideBar;
import gui.confirmationIcon;
import gui.gameMenu;
import particles.explosion;
import particles.helix;
import particles.smokeParticle;
@ -71,7 +72,8 @@ public class postProcessingThread implements Runnable{
public static textRenderer theTextRenderer;
public static boolean gamePaused;
public static boolean gamePaused, gameStarted, gameEnded;
//A pool of vectors which will be used for vector arithmetic
public static vector
@ -194,6 +196,9 @@ public class postProcessingThread implements Runnable{
if(!gamePaused)
doPostProcesssing();
gameMenu.updateAndDraw(currentScreen, gameStarted, gamePaused);
frameIndex++;
}
@ -351,356 +356,356 @@ public class postProcessingThread implements Runnable{
}
if(gameStarted) {
//create helix particles that are spawned by stealth tank's railgun trail.
for(int i = 0; i < helixCount; i++){
tempFloat = helixInfo[i];
railgunHelix[currentHelix].setActive(tempFloat[0], tempFloat[1], tempFloat[2], (int)tempFloat[3]);
currentHelix++;
currentHelix%=1500;
}
//draw helix particles
for(int i = 0; i < 1500; i++){
if(railgunHelix[i].isInAction)
railgunHelix[i].updateAndDraw();
}
//draw explosion sprite
for(int i = 0; i < 200; i++)
explosions[i].drawExplosionSprite();
//create helix particles that are spawned by stealth tank's railgun trail.
for(int i = 0; i < helixCount; i++){
tempFloat = helixInfo[i];
railgunHelix[currentHelix].setActive(tempFloat[0], tempFloat[1], tempFloat[2], (int)tempFloat[3]);
currentHelix++;
currentHelix%=1500;
}
//draw helix particles
for(int i = 0; i < 1500; i++){
if(railgunHelix[i].isInAction)
railgunHelix[i].updateAndDraw();
}
//draw explosion sprite
for(int i = 0; i < 200; i++)
explosions[i].drawExplosionSprite();
//create smoke particles
for(int i = 0; i < smokeEmmiterCount; i++){
tempFloat = smokeEmmiterList[i];
smokeParticles[currentParticleIndex].setActive(tempFloat[0], tempFloat[1], tempFloat[2], tempFloat[3], (int)tempFloat[4] , (int)tempFloat[5], tempFloat[6]);
currentParticleIndex++;
currentParticleIndex%=2000;
}
//draw smoke particles
for(int i = 0; i < 2000; i++){
if(smokeParticles[i].isInAction)
smokeParticles[i].updateAndDraw();
}
//draw health bar/Group info/unit level for every selected unit
for(int i = 0; i < 100; i++){
if(currentSelectedUnitsInfo[i][0] != -1){
ObjectType = (currentSelectedUnitsInfo[i][0] & 0xff);
groupNo = ((currentSelectedUnitsInfo[i][0] & 0xff00) >> 8);
level = ((currentSelectedUnitsInfo[i][0] & 0xff0000) >> 16);
maxHealth = unitInfoTable[ObjectType][0];
healthBarLength = unitInfoTable[ObjectType][1];
xPos = currentSelectedUnitsInfo[i][1] + unitInfoTable[ObjectType][2];
yPos = currentSelectedUnitsInfo[i][2] + unitInfoTable[ObjectType][3];
remainingHealth = healthBarLength * currentSelectedUnitsInfo[i][4] / maxHealth;
//draw group info
if(groupNo != 255){
theTextRenderer.drawText_outline(xPos, yPos + 3, ""+(groupNo+1), currentScreen, 0xffffff, 0);
}
if(level != 0){
theTextRenderer.drawStarCharacter(xPos + healthBarLength - 13, yPos + 5, level, currentScreen, 0xffff33, 0);
}
if(remainingHealth <= 2 && remainingHealth != 0)
remainingHealth = 2;
if(ObjectType != 103){
if(yPos > 0 && yPos < 512){
if(xPos >= 0 && xPos < 768)
currentScreen[xPos + yPos*768] = (currentScreen[xPos + yPos*768]&0xFEFEFE)>>1;
for(int j = xPos+1; j < xPos + healthBarLength-1; j++){
if(j < 0 || j >= 768)
continue;
currentScreen[j + yPos*768] = 0;
}
if(xPos + healthBarLength-1 >= 0 && xPos + healthBarLength-1 < 768)
currentScreen[xPos + healthBarLength-1 + yPos*768] = (currentScreen[xPos + healthBarLength-1 + yPos*768]&0xFEFEFE)>>1;
//create smoke particles
for(int i = 0; i < smokeEmmiterCount; i++){
tempFloat = smokeEmmiterList[i];
smokeParticles[currentParticleIndex].setActive(tempFloat[0], tempFloat[1], tempFloat[2], tempFloat[3], (int)tempFloat[4] , (int)tempFloat[5], tempFloat[6]);
currentParticleIndex++;
currentParticleIndex%=2000;
}
//draw smoke particles
for(int i = 0; i < 2000; i++){
if(smokeParticles[i].isInAction)
smokeParticles[i].updateAndDraw();
}
//draw health bar/Group info/unit level for every selected unit
for(int i = 0; i < 100; i++){
if(currentSelectedUnitsInfo[i][0] != -1){
ObjectType = (currentSelectedUnitsInfo[i][0] & 0xff);
groupNo = ((currentSelectedUnitsInfo[i][0] & 0xff00) >> 8);
level = ((currentSelectedUnitsInfo[i][0] & 0xff0000) >> 16);
maxHealth = unitInfoTable[ObjectType][0];
healthBarLength = unitInfoTable[ObjectType][1];
xPos = currentSelectedUnitsInfo[i][1] + unitInfoTable[ObjectType][2];
yPos = currentSelectedUnitsInfo[i][2] + unitInfoTable[ObjectType][3];
remainingHealth = healthBarLength * currentSelectedUnitsInfo[i][4] / maxHealth;
//draw group info
if(groupNo != 255){
theTextRenderer.drawText_outline(xPos, yPos + 3, ""+(groupNo+1), currentScreen, 0xffffff, 0);
}
if(level != 0){
theTextRenderer.drawStarCharacter(xPos + healthBarLength - 13, yPos + 5, level, currentScreen, 0xffff33, 0);
}
if((float)remainingHealth / healthBarLength > 0.5)
color = 0xdd00;
else if((float)remainingHealth / healthBarLength > 0.25)
color = 0xdddd00;
else
color = 0xdd0000;
if(remainingHealth <= 2 && remainingHealth != 0)
remainingHealth = 2;
for(int k = 0; k < 2; k++){
yPos++;
if(ObjectType != 103){
if(yPos > 0 && yPos < 512){
for(int j = xPos; j < xPos + healthBarLength; j++){
if(xPos >= 0 && xPos < 768)
currentScreen[xPos + yPos*768] = (currentScreen[xPos + yPos*768]&0xFEFEFE)>>1;
for(int j = xPos+1; j < xPos + healthBarLength-1; j++){
if(j < 0 || j >= 768)
continue;
if(j < xPos + remainingHealth)
currentScreen[j + yPos*768] = color;
else
currentScreen[j + yPos*768] = (currentScreen[j + yPos*768]&0xFEFEFE)>>1;
currentScreen[j + yPos*768] = 0;
}
if(xPos > 0 && xPos < 768)
currentScreen[xPos + yPos*768] = 0;
if(xPos + healthBarLength -1 >0 && xPos + healthBarLength - 1 < 768)
currentScreen[xPos + healthBarLength -1 + yPos*768] = 0;
if(xPos + healthBarLength-1 >= 0 && xPos + healthBarLength-1 < 768)
currentScreen[xPos + healthBarLength-1 + yPos*768] = (currentScreen[xPos + healthBarLength-1 + yPos*768]&0xFEFEFE)>>1;
}
}
yPos++;
if(yPos > 0 && yPos < 512){
if(xPos >= 0 && xPos < 768)
currentScreen[xPos + yPos*768] = (currentScreen[xPos + yPos*768]&0xFEFEFE)>>1;
for(int j = xPos+1; j < xPos + healthBarLength-1; j++){
if(j < 0 || j >= 768)
continue;
currentScreen[j + yPos*768] = 0;
}
if(xPos + healthBarLength-1 >= 0 && xPos + healthBarLength-1 < 768)
currentScreen[xPos + healthBarLength-1 + yPos*768] = (currentScreen[xPos + healthBarLength-1 + yPos*768]&0xFEFEFE)>>1;
}
}
//draw progress bar if appliable
if(currentSelectedUnitsInfo[i][5] >=0){
int progress = healthBarLength * currentSelectedUnitsInfo[i][5] / 100;
if(yPos > 0 && yPos < 512){
if(xPos >= 0 && xPos < 768)
currentScreen[xPos + yPos*768] = (currentScreen[xPos + yPos*768]&0xFEFEFE)>>1;
for(int j = xPos+1; j < xPos + healthBarLength-1; j++){
if(j < 0 || j >= 768)
continue;
currentScreen[j + yPos*768] = 0;
}
if(xPos + healthBarLength-1 >= 0 && xPos + healthBarLength-1 < 768)
currentScreen[xPos + healthBarLength-1 + yPos*768] = (currentScreen[xPos + healthBarLength-1 + yPos*768]&0xFEFEFE)>>1;
}
color = 0xd0b000;
for(int k = 0; k < 2; k++){
yPos++;
if((float)remainingHealth / healthBarLength > 0.5)
color = 0xdd00;
else if((float)remainingHealth / healthBarLength > 0.25)
color = 0xdddd00;
else
color = 0xdd0000;
for(int k = 0; k < 2; k++){
yPos++;
if(yPos > 0 && yPos < 512){
for(int j = xPos; j < xPos + healthBarLength; j++){
if(j < 0 || j >= 768)
continue;
if(j < xPos + remainingHealth)
currentScreen[j + yPos*768] = color;
else
currentScreen[j + yPos*768] = (currentScreen[j + yPos*768]&0xFEFEFE)>>1;
}
if(xPos > 0 && xPos < 768)
currentScreen[xPos + yPos*768] = 0;
if(xPos + healthBarLength -1 >0 && xPos + healthBarLength - 1 < 768)
currentScreen[xPos + healthBarLength -1 + yPos*768] = 0;
}
}
yPos++;
if(yPos > 0 && yPos < 512){
for(int j = xPos; j < xPos + healthBarLength; j++){
if(xPos >= 0 && xPos < 768)
currentScreen[xPos + yPos*768] = (currentScreen[xPos + yPos*768]&0xFEFEFE)>>1;
for(int j = xPos+1; j < xPos + healthBarLength-1; j++){
if(j < 0 || j >= 768)
continue;
if(j < xPos + progress)
currentScreen[j + yPos*768] = color;
else
currentScreen[j + yPos*768] = (currentScreen[j + yPos*768]&0xFEFEFE)>>1;
currentScreen[j + yPos*768] = 0;
}
if(xPos > 0 && xPos < 768)
currentScreen[xPos + yPos*768] = 0;
if(xPos + healthBarLength -1 >0 && xPos + healthBarLength - 1 < 768)
currentScreen[xPos + healthBarLength -1 + yPos*768] = 0;
if(xPos + healthBarLength-1 >= 0 && xPos + healthBarLength-1 < 768)
currentScreen[xPos + healthBarLength-1 + yPos*768] = (currentScreen[xPos + healthBarLength-1 + yPos*768]&0xFEFEFE)>>1;
}
}
//draw progress bar if appliable
if(currentSelectedUnitsInfo[i][5] >=0){
int progress = healthBarLength * currentSelectedUnitsInfo[i][5] / 100;
if(yPos > 0 && yPos < 512){
if(xPos >= 0 && xPos < 768)
currentScreen[xPos + yPos*768] = (currentScreen[xPos + yPos*768]&0xFEFEFE)>>1;
for(int j = xPos+1; j < xPos + healthBarLength-1; j++){
if(j < 0 || j >= 768)
continue;
currentScreen[j + yPos*768] = 0;
}
if(xPos + healthBarLength-1 >= 0 && xPos + healthBarLength-1 < 768)
currentScreen[xPos + healthBarLength-1 + yPos*768] = (currentScreen[xPos + healthBarLength-1 + yPos*768]&0xFEFEFE)>>1;
}
color = 0xd0b000;
for(int k = 0; k < 2; k++){
yPos++;
if(yPos > 0 && yPos < 512){
for(int j = xPos; j < xPos + healthBarLength; j++){
if(j < 0 || j >= 768)
continue;
if(j < xPos + progress)
currentScreen[j + yPos*768] = color;
else
currentScreen[j + yPos*768] = (currentScreen[j + yPos*768]&0xFEFEFE)>>1;
}
if(xPos > 0 && xPos < 768)
currentScreen[xPos + yPos*768] = 0;
if(xPos + healthBarLength -1 >0 && xPos + healthBarLength - 1 < 768)
currentScreen[xPos + healthBarLength -1 + yPos*768] = 0;
}
}
}
yPos++;
if(yPos > 0 && yPos < 512){
if(xPos >= 0 && xPos < 768)
currentScreen[xPos + yPos*768] = (currentScreen[xPos + yPos*768]&0xFEFEFE)>>1;
for(int j = xPos+1; j < xPos + healthBarLength-1; j++){
if(j < 0 || j >= 768)
continue;
currentScreen[j + yPos*768] = 0;
yPos++;
if(yPos > 0 && yPos < 512){
if(xPos >= 0 && xPos < 768)
currentScreen[xPos + yPos*768] = (currentScreen[xPos + yPos*768]&0xFEFEFE)>>1;
for(int j = xPos+1; j < xPos + healthBarLength-1; j++){
if(j < 0 || j >= 768)
continue;
currentScreen[j + yPos*768] = 0;
}
if(xPos + healthBarLength-1 >= 0 && xPos + healthBarLength-1 < 768)
currentScreen[xPos + healthBarLength-1 + yPos*768] = (currentScreen[xPos + healthBarLength-1 + yPos*768]&0xFEFEFE)>>1;
}
if(xPos + healthBarLength-1 >= 0 && xPos + healthBarLength-1 < 768)
currentScreen[xPos + healthBarLength-1 + yPos*768] = (currentScreen[xPos + healthBarLength-1 + yPos*768]&0xFEFEFE)>>1;
}
}
}
}
//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);
//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 j = 0; j < radius; j++, index++, destIndex -=512){
temp = temp - fogOfWarBuffer[index - radius] + 43;
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);
for(int i = 0; i < 512; i++){
xMin[i] = 378;
xMax[i] = 378;
}
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);
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;
}
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;
}
}
//draw select rectangle
if(mainThread.pc.isSelectingUnit){
xPos = mainThread.pc.area.x;
yPos = mainThread.pc.area.y;
selectAreaWidth = mainThread.pc.area.width;
selectAreaHeight = mainThread.pc.area.height;
try{
if(!(yPos == 511 || xPos == 767)){
for(int i = xPos; i < xPos + selectAreaWidth; i++)
currentScreen[i + yPos*768] = 0xaa00;
for(int i = xPos; i < xPos + selectAreaWidth; i++)
currentScreen[i + (yPos + 1)*768] = 0xcc00;
for(int i = xPos; i < xPos + selectAreaWidth; i++)
currentScreen[i + (yPos+selectAreaHeight-1)*768] = 0xcc00;
for(int i = xPos; i < xPos + selectAreaWidth; i++)
currentScreen[i + (yPos + selectAreaHeight)*768] = 0xaa00;
for(int i = yPos; i < yPos + selectAreaHeight; i++)
currentScreen[xPos + i*768] = 0xaa00;
for(int i = yPos+1; i < yPos + selectAreaHeight-1; i++)
currentScreen[xPos + 1 + i*768] = 0xcc00;
for(int i = yPos; i < yPos + selectAreaHeight; i++)
currentScreen[xPos + selectAreaWidth + i*768] = 0xaa00;
for(int i = yPos + 1; i < yPos + selectAreaHeight - 1; i++)
currentScreen[xPos - 1 + selectAreaWidth + i*768] = 0xcc00;
//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]];
}
}catch(Exception e){}
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;
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);
}
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);
}
}
//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;
}
}
//draw select rectangle
if(mainThread.pc.isSelectingUnit){
xPos = mainThread.pc.area.x;
yPos = mainThread.pc.area.y;
selectAreaWidth = mainThread.pc.area.width;
selectAreaHeight = mainThread.pc.area.height;
try{
if(!(yPos == 511 || xPos == 767)){
for(int i = xPos; i < xPos + selectAreaWidth; i++)
currentScreen[i + yPos*768] = 0xaa00;
for(int i = xPos; i < xPos + selectAreaWidth; i++)
currentScreen[i + (yPos + 1)*768] = 0xcc00;
for(int i = xPos; i < xPos + selectAreaWidth; i++)
currentScreen[i + (yPos+selectAreaHeight-1)*768] = 0xcc00;
for(int i = xPos; i < xPos + selectAreaWidth; i++)
currentScreen[i + (yPos + selectAreaHeight)*768] = 0xaa00;
for(int i = yPos; i < yPos + selectAreaHeight; i++)
currentScreen[xPos + i*768] = 0xaa00;
for(int i = yPos+1; i < yPos + selectAreaHeight-1; i++)
currentScreen[xPos + 1 + i*768] = 0xcc00;
for(int i = yPos; i < yPos + selectAreaHeight; i++)
currentScreen[xPos + selectAreaWidth + i*768] = 0xaa00;
for(int i = yPos + 1; i < yPos + selectAreaHeight - 1; i++)
currentScreen[xPos - 1 + selectAreaWidth + i*768] = 0xcc00;
}
}catch(Exception e){}
}
//draw confirmation icon
if(confirmationIconInfo[0] != 0){
theConfirmationIcon.setActive((float)confirmationIconInfo[1], (float)confirmationIconInfo[2], (int)confirmationIconInfo[3]);
}
theConfirmationIcon.updateAndDraw();
for(int i = 0; i < confirmationIconInfo.length; i++){
confirmationIconInfo[i] = 0;
}
//draw mini map
theMiniMap.draw(currentScreen, minimapBitmap, unitsForMiniMap, unitsForMiniMapCount);
theSideBar.draw(currentScreen, sideBarInfo);
}
//draw confirmation icon
if(confirmationIconInfo[0] != 0){
theConfirmationIcon.setActive((float)confirmationIconInfo[1], (float)confirmationIconInfo[2], (int)confirmationIconInfo[3]);
}
theConfirmationIcon.updateAndDraw();
for(int i = 0; i < confirmationIconInfo.length; i++){
confirmationIconInfo[i] = 0;
}
//draw mini map
theMiniMap.draw(currentScreen, minimapBitmap, unitsForMiniMap, unitsForMiniMapCount);
theSideBar.draw(currentScreen, sideBarInfo);
}
//start rasterization
@ -931,6 +936,11 @@ public class postProcessingThread implements Runnable{
}
public static void prepareResources(){
gamePaused = mainThread.gamePaused;
gameStarted = mainThread.gameStarted;
gameEnded = mainThread.gameEnded;
currentScreen = mainThread.screen;
currentZbuffer = mainThread.zBuffer;
displacementBuffer = mainThread.displacementBuffer;
@ -947,7 +957,11 @@ public class postProcessingThread implements Runnable{
helixCount = mainThread.theAssetManager.helixCount;
smokeEmmiterList = mainThread.theAssetManager.smokeEmmiterList;
smokeEmmiterCount = mainThread.theAssetManager.smokeEmmiterCount;
sideBarInfo = mainThread.pc.theSideBarManager.sideBarInfo;
if(gameStarted) {
sideBarInfo = mainThread.pc.theSideBarManager.sideBarInfo;
playerMoney = mainThread.pc.theBaseInfo.currentCredit;
playerPowerStatus = mainThread.pc.theBaseInfo.powerStatus;
}
confirmationIconInfo = mainThread.theAssetManager.confirmationIconInfo;
cameraPosition.set(camera.position);
@ -959,9 +973,7 @@ public class postProcessingThread implements Runnable{
theMiniMap.findCorners();
playerMoney = mainThread.pc.theBaseInfo.currentCredit;
playerPowerStatus = mainThread.pc.theBaseInfo.powerStatus;
gamePaused = mainThread.gamePaused;
}

View File

@ -60,7 +60,7 @@ public class enemyCommander {
thinkHardLikeHumanPlayer();
drawVisionMap();
//drawVisionMap();
//reset tempBitmap;
for(int i = 0 ;i < tempBitmap.length; i++){

View File

@ -263,14 +263,17 @@ public class goldMine extends solidObject{
//update the model
public void update(){
if(mainThread.theAssetManager.minimapBitmap[tileIndex[0]] ||
mainThread.theAssetManager.minimapBitmap[tileIndex[1]] ||
mainThread.theAssetManager.minimapBitmap[tileIndex[2]] ||
mainThread.theAssetManager.minimapBitmap[tileIndex[3]] )
isRevealed = true;
else
isRevealed = false;
if(!mainThread.gameStarted) {
isRevealed = true;
}else {
if(mainThread.theAssetManager.minimapBitmap[tileIndex[0]] ||
mainThread.theAssetManager.minimapBitmap[tileIndex[1]] ||
mainThread.theAssetManager.minimapBitmap[tileIndex[2]] ||
mainThread.theAssetManager.minimapBitmap[tileIndex[3]] )
isRevealed = true;
else
isRevealed = false;
}
if(isRevealed){
//check if gold mine has been depleted

View File

@ -22,7 +22,7 @@ public class palmTree extends solidObject{
public final static Rectangle screenBoundary = new Rectangle(40,40,688, 432);
//screen space boundary which is used to test if the shadow of the object is within the screen
public final static Rectangle shadowBoundary1 = new Rectangle(-20, -20,808, 552);
public final static Rectangle shadowBoundary1 = new Rectangle(0,0,768, 512);
//palmTrees never moves
public final static vector movenment = new vector(0,0,0);
@ -255,7 +255,8 @@ public class palmTree extends solidObject{
tempCentre.rotate_YZ(camera.YZ_angle);
tempCentre.updateLocation();
if(tempCentre.screenX > 918 || tempCentre.screenX < - 50 || tempCentre.screenY < - 125 || tempCentre.screenY > 662){
if(tempCentre.screenX > 918 || tempCentre.screenX < - 150 || tempCentre.screenY < - 150 || tempCentre.screenY > 662){
visible = false;
return;
}

1
gui/.gitignore vendored
View File

@ -5,3 +5,4 @@
/inputHandler.class
/playerCommander.class
/sideBarManager.class
/gameMenu.class

View File

@ -53,7 +53,6 @@ public class MiniMap {
for(int i = 0; i < minimapBitmap.length; i++)
minimapBitmap[i] = true;
//draw unit positions on minimap
drawUnit(screen, minimapBitmap, unitsForMiniMap, unitsForMiniMapCount);

20
gui/gameMenu.java Normal file
View File

@ -0,0 +1,20 @@
package gui;
import core.*;
public class gameMenu {
public static int menuStatus = 0;
public static final int mainMenu = 0;
public static final int difficulitySelectionMenu = 1;
public static final int helpMenu = 2;
public static final int endGameMenu = 3;
public static void updateAndDraw(int[] screen, boolean gameStarted, boolean gamePaused) {
}
}

View File

@ -124,7 +124,7 @@ public class inputHandler {
//handle input when game is running
if(!mainThread.gamePaused){
if(!mainThread.gamePaused && mainThread.gameStarted){
if(!mainThread.pc.isSelectingUnit){
mouse_x0 = mouse_x;
mouse_y0 = mouse_y;
@ -243,14 +243,14 @@ public class inputHandler {
//handle escape key
if(escapeKeyReleased) {
mainThread.gamePaused = true; //when game is running, pause the game when esc key is hit
mainThread.gamePaused = true; //if game is running, pause the game when esc key is hit
}
}else {
//handle event when game is paused
if(escapeKeyReleased)
mainThread.gamePaused = false; //when game is paused unpause the game when esc key is hit
if(escapeKeyReleased && mainThread.gameStarted)
mainThread.gamePaused = false; //if game is paused, unpause the game when esc key is hit
}