package md.obama.game; import java.awt.Container; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.io.File; import java.text.DecimalFormat; import java.util.Formatter; import java.util.Scanner; import javax.swing.JOptionPane; import javax.swing.JPanel; import md.obama.game.entities.buildings.Booster; import md.obama.game.entities.buildings.Building; import md.obama.game.entities.buildings.MetalExtractor; import md.obama.game.entities.buildings.SolarArray; import md.obama.game.gfx.Colours; import md.obama.game.gfx.Font; import md.obama.game.gfx.Screen; import md.obama.game.level.GenerateLevel; import md.obama.game.level.Level; public class GameHandler extends JPanel implements MouseListener, MouseMotionListener{ /** * Really */ private static final long serialVersionUID = 1L; private static final byte GRIDMAX = 14; private static final byte GRIDMIN = 0; private final Container cc = getRootPane(); private boolean can_generate = true; GenerateLevel genLvl = new GenerateLevel(); //Metal public double metalBank=8; public float metalPerSecond=1; public int metalClicked=0; public int metalPerClick=1; public int metalFromClicking=0; public int metalFromBuildings=0; public int totalTicks=0; //Energy public double energyMax=0; //Max allowed energy public double energyUse=0; //Current energy consumption public Level level; public Screen screen; //debug vars //private boolean skip_ask = false; private boolean skip_cost = false; private boolean debug_help = false; //buying / placing things private boolean placing = false; private boolean moving = false; private short place_id = 0; int mouse_y = 200; int mouse_x = 200; private byte place_sprite_x=0, place_sprite_y=0; int place_color = Colours.get(000, 222, 444, 333); //stats int stat_id; int stat_lvl; int stat_x; int stat_y; double stat_meCost; double stat_enCost; double stat_enUsed; double stat_product; double stat_productB; float stat_pboost; boolean show_stats = false; Building stat_ding; DecimalFormat df = new DecimalFormat("###.##"); @Override public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); int gridX = Math.round(x/16/2)-12; int gridY = Math.round(y/16/2)-1; if(e.getButton() == MouseEvent.BUTTON3){ System.out.printf("Coords: %s,%s tiled: %s,%s Grid: %s,%s\n", x, y, x/8, y/8, gridX, gridY); placing = false; moving = false; } else if(placing == false){ if(boxed(x,y,1, 456, 400, 40)){ //Click the ore for metal metalBank += metalPerClick; metalFromClicking += metalPerClick; metalClicked++; System.out.printf("Total metal! %s, Metal clicked %s.\n", ((long)Math.floor(metalBank)), metalClicked); } if(boxed(x,y,1, 500, 400, 20) && debug_help){ //Just increases metal per click. metalPerClick++; metalPerSecond+=5; System.out.printf("Metal per click %s, Metal from clicking %s.\n", metalPerClick, metalFromClicking); } /* if(mouse_x >= 388 && mouse_y >=34 && mouse_x <=863 && mouse_y <=498){ //Clicking a building if(Building.build[gridX][gridY] != null){ Building ding = Building.build[gridX][gridY]; updateEnergy(); if(ding.id==1){ //Metal extractor clickExtractor(ding, false); } else if (ding.id == 2) { // Booster clickBooster(ding, false); } else if (ding.id == 3) { // Solar Array clickSolarArray(ding, false); } } }*/ gridX = Math.round(x/32)-12; gridY = Math.round(y/32)-1; if(gridX >=GRIDMIN && gridY >= GRIDMIN && gridX <=GRIDMAX && gridY <= GRIDMAX){ if(moving){ if(Building.build[gridX][gridY] == null){ //if it is empty Building.build[gridX][gridY] = Building.build[stat_x][stat_y]; Building.build[stat_x][stat_y] = null; Building ding = Building.build[gridX][gridY]; ding.setGrid(gridX,gridY); updateStats(ding, gridX, gridY); show_stats = true; moving = false; } } //if we're not moving and we click another building else if(Building.build[gridX][gridY] != null){ Building ding = Building.build[gridX][gridY]; //clicking to show stats updateStats(ding, gridX, gridY); show_stats = true; } } if(show_stats){ if(boxed(x,y,0,375,115,20)){ //UPGRADE BUTTON updateEnergy(); if(stat_ding.id==1){ //Metal extractor clickExtractor(stat_ding); } else if (stat_ding.id == 2) { // Booster clickBooster(stat_ding); } else if (stat_ding.id == 3) { // Solar Array clickSolarArray(stat_ding); } updateStats(stat_ding, stat_ding.gridX, stat_ding.gridY); } else if(boxed(x,y,140,375,65,20)){ //MOVE BUTTON moving = true; Building ding = Building.build[stat_x][stat_y]; place_id = ding.id; place_sprite_x = (byte) ding.x; place_sprite_y = (byte) ding.y; place_color = ding.getTileColour(); } else if(boxed(x,y,240,375,70,20)){ //SELL BUTTON if(JOptionPane.showConfirmDialog(cc, "Sell building?")==0){ double enCost = stat_ding.getEnergyCost(); double enUsed = stat_ding.getEnergyUsed(); int lvl = stat_ding.getUpgrade(); metalBank += ((enUsed*enCost)*2)*lvl; Building.build[stat_x][stat_y] = null; tick(false); //update the metal bank on screen } } } } else{ //Place buildings if(placing){ gridX = Math.round(x/32)-12; gridY = Math.round(y/32)-1; int xx = (gridX*2)+24; int yy = (gridY*2)+1; if(gridX >=0 && gridY >= 0 && gridX <=14 && gridY <= 14){ if(place_id==1){//Metal Extractor if(Building.build[gridX][gridY] == null){ if(level.getTile(xx,yy).getId()==5 && level.getTile(xx+1,yy).getId()==6 && level.getTile(xx,yy+1).getId()==7 && level.getTile(xx+1,yy+1).getId()==8){ new MetalExtractor(null, 1, place_sprite_x, place_sprite_y,gridX,gridY, place_color); placing = false; metalBank -= 10; updateEnergy(); } } } else if(place_id==2){ //Booster if(Building.build[gridX][gridY] == null){ if(level.getTile(xx,yy).getId()==2 && level.getTile(xx+1,yy).getId()==2 && level.getTile(xx,yy+1).getId()==2 && level.getTile(xx+1,yy+1).getId()==2){ new Booster(null, 2, place_sprite_x, place_sprite_y,gridX,gridY, place_color); placing = false; metalBank -= 20; updateEnergy(); } } } else if(place_id==3){ //Solar Array if(Building.build[gridX][gridY] == null){ if(level.getTile(xx,yy).getId()==2 && level.getTile(xx+1,yy).getId()==2 && level.getTile(xx,yy+1).getId()==2 && level.getTile(xx+1,yy+1).getId()==2){ new SolarArray(null, 3, place_sprite_x, place_sprite_y,gridX,gridY, place_color); placing = false; metalBank -= 8; updateEnergy(); } } } if(can_generate) can_generate = false; } } } } private void updateStats(Building ding, int gridX, int gridY) { float boost; stat_ding = ding; stat_id = ding.id; stat_lvl = ding.getUpgrade(); stat_x = gridX; stat_y = gridY; stat_meCost = ding.getMetalCost(); stat_enCost = ding.getEnergyCost(); stat_enUsed = ding.getEnergyUsed(); stat_product = getProduct(ding); boost = 1; if(stat_x != 14) {boost = getBoost(stat_x+1,stat_y,boost);} if(stat_x != 1) {boost = getBoost(stat_x-1,stat_y,boost);} if(stat_y != 14) {boost = getBoost(stat_x,stat_y+1,boost);} if(stat_y != 1) {boost = getBoost(stat_x,stat_y-1,boost);} stat_productB = stat_product*boost; stat_pboost = boost; if(stat_id==3){ //Solar array receives half the benefit of boosters stat_productB/=2; stat_pboost/=2; } } private double getProduct(Building ding) { double it; switch (ding.id){ default: case 1: it = ((MetalExtractor)ding).getMetalGen(); break; case 2: it = ((Booster)ding).getBoosting(); break; case 3: it = ((SolarArray)ding).getEnergy(); break; } return it; } private void clickSolarArray(Building ding) { double meCost = ((SolarArray) ding).getMetalCost(); double toBoost; if (this.metalBank >= meCost || skip_cost){ //If we have enough metal, or if debug is enabled if(!skip_cost){ this.metalBank -= meCost; } //Don't apply the cost if debug meCost = (meCost+2)*1.28; //Increase the cost for the next upgrade toBoost = (((SolarArray) ding).getEnergy()+1)*1.02; //What we will upgrade it by ((SolarArray) ding).setEnergy(toBoost); ((SolarArray) ding).setMetalCost(meCost); ((SolarArray) ding).setUpgrade((((SolarArray) ding).getUpgrade() + 1)); System.out.println("Upgraded Solar Array to " + df.format(((SolarArray) ding).getEnergy()) + " level: " + ((SolarArray) ding).getUpgrade() + " metalCost: " + df.format(meCost)); tick(false); } } private void clickExtractor(Building ding) { double meCost = ((MetalExtractor) ding).getMetalCost(); double enCost = ((MetalExtractor) ding).getEnergyCost(); double enUsed = ((MetalExtractor) ding).getEnergyUsed(); double toGen; double enBoth = enCost + enUsed; if ((this.metalBank >= meCost && (this.energyUse + enCost <= this.energyMax))|| skip_cost){ //If we have enough metal, or if debug is enabled if(!skip_cost){ this.metalBank -= meCost; ((MetalExtractor) ding).setEnergyUsed(enBoth); } //Don't apply the cost if debug meCost = (meCost+2)*1.21; //Increase the cost for the next upgrade enCost = (enCost)*1.075; toGen = ((((MetalExtractor) ding).getMetalGen()+0.70)*1.065f); //What we will upgrade it to ((MetalExtractor) ding).setMetalGen(toGen); ((MetalExtractor) ding).setMetalCost(meCost); ((MetalExtractor) ding).setEnergyCost(enCost); ((MetalExtractor) ding).setUpgrade((((MetalExtractor) ding).getUpgrade() + 1)); System.out.println("Upgraded Metal Extractor to " + df.format(((MetalExtractor) ding).getMetalGen()) + " level: " + ((MetalExtractor) ding).getUpgrade() + " metalCost: " + df.format(meCost)); tick(false); } } private void clickBooster(Building ding) { double meCost = ((Booster) ding).getMetalCost(); double enCost = ((Booster) ding).getEnergyCost(); double enUsed = ((Booster) ding).getEnergyUsed(); float toBoost; double enBoth = enCost + enUsed; if ((this.metalBank >= meCost && (this.energyUse + enCost <= this.energyMax))|| skip_cost){ //If we have enough metal, or if debug is enabled if(!skip_cost){ this.metalBank -= meCost; ((Booster) ding).setEnergyUsed(enBoth); } //Don't apply the cost if debug meCost = (meCost+3)*1.32; //Increase the cost for the next upgrade enCost = (enCost)*1.125; toBoost = (float) (((Booster) ding).getBoosting()*1.11); ((Booster) ding).setBoosting(toBoost); ((Booster) ding).setMetalCost(meCost); ((Booster) ding).setEnergyCost(enCost); ((Booster) ding).setUpgrade((((Booster) ding).getUpgrade() + 1)); System.out.println("Upgraded Booster to " + df.format(((Booster) ding).getBoosting()) + " level: " + ((Booster) ding).getUpgrade() + " metalCost: " + df.format(meCost)); tick(false); } } public void tick(boolean add){ //Update bank every second. this.metalPerSecond = 0; double income = getIncome(); this.metalPerSecond += income; if(add){ this.metalBank += this.metalPerSecond; this.metalFromBuildings += this.metalPerSecond; this.totalTicks++; if(this.totalTicks>=300) { //Save game every 5 minutes saveGame(); this.totalTicks=0; } } updateEnergy(); } private boolean boxed(int x, int y, int xp, int yp, int xl, int yl) { if (x < xp || x > (xp+xl)) return false; if (y < yp || y > (yp+yl)) { return false; } else return true; } public float getIncome(){ float metal=0, boost; double exMetal; for(int xx=0; xx<15; xx++){ for(int yy=0; yy<15; yy++){ if(Building.build[xx][yy]!=null){ Building ding = Building.build[xx][yy]; if(ding.id==1){ exMetal = ((MetalExtractor) ding).metalGen; boost = 1; if(xx != 14) {boost = getBoost(xx+1,yy,boost);} if(xx != 1) {boost = getBoost(xx-1,yy,boost);} if(yy != 14) {boost = getBoost(xx,yy+1,boost);} if(yy != 1) {boost = getBoost(xx,yy-1,boost);} exMetal *= boost; metal+=exMetal; //System.out.println("boosting by "+ boost); } } } } //System.out.println("it is by "+ metal); return metal; } public void updateEnergy(){ float boost; double enUse=0, exEnergy=0, energy=0; for(int xx=0; xx<15; xx++){ for(int yy=0; yy<15; yy++){ if(Building.build[xx][yy]!=null){ Building ding = Building.build[xx][yy]; if(ding.id==1) enUse+= ((MetalExtractor)ding).getEnergyUsed(); if(ding.id==2) enUse+= ((Booster)ding).getEnergyUsed(); if(ding.id==3){ //Solar Array exEnergy=((SolarArray) ding).getEnergy(); boost = 1; if(xx != 14) {boost = getBoost(xx+1,yy,boost);} if(xx != 1) {boost = getBoost(xx-1,yy,boost);} if(yy != 14) {boost = getBoost(xx,yy+1,boost);} if(yy != 1) {boost = getBoost(xx,yy-1,boost);} if(boost!=0){ boost/=2; //Solar arrays gain half the benefit of boosters. exEnergy *= boost; } energy+=exEnergy; } } } } this.energyMax = energy; this.energyUse = enUse; } private static float getBoost(int xx, int yy, float boost) { if(xx >=0 && yy >= 0 && xx <=14 && yy <= 14){ if(Building.build[xx][yy]!=null){ Building ding2 = Building.build[xx][yy]; if(ding2.id==2){ boost+=((Booster) ding2).getBoosting(); } } } return boost; } public void buyExtractor(){ //location 17,13 if(metalBank>=10 && (energyUse + 2 <= energyMax)){ placing = true; place_id = 1; place_sprite_x=17; place_sprite_y=13; place_color = Colours.get(000, 222, 444, 333); } } public void buyBooster(){ //location 17,13 if(metalBank>=20 && (energyUse + 1 <= energyMax)){ placing = true; place_id = 2; place_sprite_x=17; place_sprite_y=13; place_color = Colours.get(000, 220, 440, 333); } } public void buySolarArray(){ //location 17,13 if(metalBank>=8){ placing = true; place_id = 3; place_sprite_x=17; place_sprite_y=17; place_color = Colours.get(000, 113, 225, -1); } } public void sendGenerate(){ if(can_generate){ genLvl.generateLevel(level); System.out.println("Generated land"); } } public void showStats(){ int xx = Math.round((mouse_x/32))-12; int yy = Math.round(mouse_y/32)-1; int lvl; double meCost, enCost, enUsed; if(Building.build[xx][yy] != null){ Building ding = Building.build[xx][yy]; if(ding.id==1){ double metal=0; float boost; metal = ((MetalExtractor) ding).metalGen; lvl = ((MetalExtractor) ding).getUpgrade(); meCost = ((MetalExtractor) ding).getMetalCost(); enCost = ((MetalExtractor) ding).getEnergyCost(); enUsed = ((MetalExtractor) ding).getEnergyUsed(); boost = 1; if(xx != 14) {boost = getBoost(xx+1,yy,boost);} if(xx != 1) {boost = getBoost(xx-1,yy,boost);} if(yy != 14) {boost = getBoost(xx,yy+1,boost);} if(yy != 1) {boost = getBoost(xx,yy-1,boost);} metal *= boost; JOptionPane.showMessageDialog(cc, "Level: " + lvl + "\nMetal Cost: " + df.format(meCost) + "\nEnergy Cost: " + df.format(enCost) + "\nEnergy Used: " + df.format(enUsed) + "\nProducing metal: " + df.format(metal) + "\nBoost multiplier: " + df.format(boost)); } if(ding.id==2){ float boost = ((Booster) ding).boosting; lvl = ((Booster) ding).getUpgrade(); meCost = ((Booster) ding).getMetalCost(); enCost = ((Booster) ding).getEnergyCost(); enUsed = ((Booster) ding).getEnergyUsed(); JOptionPane.showMessageDialog(cc, "Level: " + lvl + "\nMetal Cost: " + df.format(meCost) + "\nEnergy Cost: " + df.format(enCost) + "\nEnergy Used: " + df.format(enUsed) + "\nBoosting by: " + df.format(1+boost)); } if(ding.id==3){ double energy; float boost; lvl = ((SolarArray) ding).getUpgrade(); meCost = ((SolarArray) ding).getMetalCost(); energy = ((SolarArray) ding).energy; boost = 1; if(xx != 14) {boost = getBoost(xx+1,yy,boost);} if(xx != 1) {boost = getBoost(xx-1,yy,boost);} if(yy != 14) {boost = getBoost(xx,yy+1,boost);} if(yy != 1) {boost = getBoost(xx,yy-1,boost);} energy *= boost; JOptionPane.showMessageDialog(cc, "Level: " + lvl + "\nMetal Cost: " + df.format(meCost) + "\nEnergy Produced: " + df.format(energy)); } } } public void saveGame(){ //level.setImagePath("/levels/savegame.png"); level.saveLevelToFile(); try{ //String path = System.getProperty("user.home")+"\\MCsavegame.txt"; String path = "/savegame.txt"; File f = new File(path); if(!f.exists() && !f.isDirectory()) { f.createNewFile(); } Formatter file = new Formatter(f); String line = metalBank +"]"; for(int xx=0; xx<16; xx++){ for(int yy=0; yy<16; yy++){ if(Building.build[xx][yy]!=null){ Building ding = Building.build[xx][yy]; line += "="+ding.id+"-"; //ID of the building line += xx + "-"; //x coordinate on grid line += yy + "-"; //y coordinate on grid line += ding.getUpgrade() + "-"; //level of building line += ding.getMetalCost() + "-"; //cost to upgrade line += ding.getEnergyCost() + "-"; //cost to upgrade in energy line += ding.getEnergyUsed() + "-"; //current energy consumption if(ding.id==1){ line += ((MetalExtractor)ding).getMetalGen() + "-"; } if(ding.id==2){ line += ((Booster)ding).getBoosting() + "-"; } if(ding.id==3){ line += ((SolarArray)ding).getEnergy() + "-"; //energy production } } } } file.format("%s", line); file.close(); //close file System.out.println("Saved game"); } catch (Exception e){ System.out.println("[WARNING] Problem saving the game"); } } public void loadGame(){ level.loadLevelFromFile(); try{ //String path = System.getProperty("user.home")+"\\MCsavegame.txt"; String path = "/savegame.txt"; Scanner file = new Scanner(new File(path)); String line = file.next(); String[] bank = line.split("]"); String[] buildings = bank[1].split("="); String[] attributes = new String[8]; metalBank = Double.parseDouble(bank[0]); int x, y, lvl; double enCost, enUsed, meCost, product; Building ding; if(buildings.length>=1) can_generate = false; for(int xx=0; xx<16; xx++){ for(int yy=0; yy<16; yy++){ Building.build[xx][yy] = null; } } for(int i=1; i=1000000000) { return df.format(make/1000000000)+"b"; } else if(make>=1000000) { return df.format(make/1000000)+"m"; } else if(make>=1000) { return df.format(make/1000)+"k"; } return df.format(make); } public void render(Screen screen){ //System.out.println("test"); for(int xx=0; xx<16; xx++){ for(int yy=0; yy<16; yy++){ if(Building.build[xx][yy]!=null){ Building ding = Building.build[xx][yy]; ding.render(screen); } } } int gridX, gridY; if(placing || moving){ if(mouse_x >= 388 && mouse_y >=34 && mouse_x <=863 && mouse_y <=498){ gridX = (Math.round(mouse_x/32)*16); gridY = Math.round(mouse_y/32)*16-8; screen.render(gridX, gridY, place_sprite_x + place_sprite_y * 32, place_color, 0x00, 1); screen.render(gridX+8, gridY, (place_sprite_x+1) + place_sprite_y * 32, place_color, 0x00, 1); screen.render(gridX, gridY+8, place_sprite_x + (place_sprite_y+1) * 32, place_color, 0x00, 1); screen.render(gridX+8, gridY+8, (place_sprite_x+1) + (place_sprite_y+1) * 32, place_color, 0x00, 1); } } Font.render("Max Energy: " + (makeString(this.energyMax)), screen, 1, 0, Colours.get(-1, -1, -1, 103), 1); Font.render("Energy Used: " + (makeString(this.energyUse)), screen, 1, 10, Colours.get(-1, -1, -1, 103), 1); Font.render("Hotkeys: metal energy", screen, 1, 40, Colours.get(-1, -1, -1, 050), 1); Font.render("1 Extractor - 10m 2en", screen, 1, 50, Colours.get(-1, -1, -1, 050), 1); Font.render("2 Booster - 20m 1en", screen, 1, 60, Colours.get(-1, -1, -1, 050), 1); Font.render("3 Solar Array - 8m 0en", screen, 1, 70, Colours.get(-1, -1, -1, 050), 1); if(show_stats){ Font.render("Level: " + stat_lvl, screen, 1, 100, Colours.get(-1, -1, -1, 053), 1); Font.render("Metal Cost: " + (makeString(stat_meCost)), screen, 1, 110, Colours.get(-1, -1, -1, 053), 1); if(stat_id!=3)Font.render("Energy Cost: " + (makeString(stat_enCost)), screen, 1, 120, Colours.get(-1, -1, -1, 053), 1); if(stat_id!=3)Font.render("Energy Usage: " + (makeString(stat_enUsed)), screen, 1, 130, Colours.get(-1, -1, -1, 053), 1); String duct = "error"; if(stat_id==1) duct = "Metal: "; if(stat_id==2) duct = "Boosts by: "; if(stat_id==3) duct = "Energy: "; Font.render(duct + (makeString(stat_product)), screen, 1, 145, Colours.get(-1, -1, -1, 053), 1); if(stat_id!=2)Font.render("Boosted to: " + (makeString(stat_productB)), screen, 1, 155, Colours.get(-1, -1, -1, 053), 1); if(stat_id!=2)Font.render("Boostiplier: " + (makeString((double) stat_pboost)), screen, 1, 165, Colours.get(-1, -1, -1, 053), 1); Font.render("Upgrade", screen, 1, 185, Colours.get(-1, -1, -1, 024), 1); Font.render("Move", screen, 70, 185, Colours.get(-1, -1, -1, 024), 1); Font.render("Sell", screen, 120, 185, Colours.get(-1, -1, -1, 024), 1); //Draw the orange selected border cursor gridX = (stat_x+12)*16; gridY = (stat_y+1)*16-8; screen.render(gridX, gridY, 20 + 14 * 32, Colours.get(550, -1, -1, -1), 0x03, 1); screen.render(gridX+8, gridY, 19 + 14 * 32, Colours.get(530, -1, -1, -1), 0x03, 1); screen.render(gridX, gridY+8, 20 + 13 * 32, Colours.get(530, -1, -1, -1), 0x03, 1); screen.render(gridX+8, gridY+8, 19 + 13 * 32, Colours.get(550, -1, -1, -1), 0x03, 1); } Font.render("Click here for metal", screen, 1, 226, Colours.get(-1, -1, -1, 300), 1); Font.render("Metal: " + (makeString(this.metalBank)), screen, 1, 236, Colours.get(-1, -1, -1, 300), 1); Font.render("MetalPerSec: " + makeString((double) this.metalPerSecond), screen, 1, 246, Colours.get(-1, -1, -1, 300), 1); if(can_generate)Font.render("G to generate land", screen, 1, 30, Colours.get(-1, -1, -1, 050), 1); if(mouse_x >= 388 && mouse_y >=34 && mouse_x <=863 && mouse_y <=498){ //Draw the red border cursor gridX = (Math.round(mouse_x/32)*16); gridY = Math.round(mouse_y/32)*16-8; screen.render(gridX, gridY, 19 + 13 * 32, Colours.get(500, -1, -1, -1), 0x00, 1); screen.render(gridX+8, gridY, (19+1) + 13 * 32, Colours.get(500, -1, -1, -1), 0x00, 1); screen.render(gridX, gridY+8, 19 + (13+1) * 32, Colours.get(500, -1, -1, -1), 0x00, 1); screen.render(gridX+8, gridY+8, (19+1) + (13+1) * 32, Colours.get(500, -1, -1, -1), 0x00, 1); } Font.render("v0.09", screen, 400, 248, Colours.get(-1, -1, -1, 103), 1); } public void init(Screen screen, Level level){ this.screen = screen; this.level = level; String path = "/savegame.txt";//System.getProperty("user.home")+"\\MCsavegame.txt"; if(new File(path).exists()){ loadGame(); }else{ sendGenerate(); } } @Override public void mouseClicked(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseDragged(MouseEvent arg0) { } @Override public void mouseMoved(MouseEvent arg0) { mouse_x = arg0.getX(); mouse_y = arg0.getY(); } public Container getCc() { return cc; } }