Results 1 to 19 of 19
Like Tree2Likes
  • 1 Post By SurfMan
  • 1 Post By Norm

Thread: Help Wanted! infinite terrain

  1. #1
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Exclamation Help Wanted! infinite terrain

    hello i am the creator of a game called blocaria its been out for a year now you can find it on indiedb its been top 100 twice by the way and i really want to add infinite terrain i had a go at it with arrays and LinkedList Queue etc and couldnt get it to work i want chunks to be 25 by 25 if you help and succeed you will have a place in the credits and i will create a tab under developers assist developers inwhich your name will be place and in brackets what you assisted with if you think you can help

    please email me at
    DRAGONMASTER412@googlemail.com

    and have the subject as Blocaria infinite terrain help

    i will then send you a email with the src attached you do not need any game librarys because it is pure

    thanks for your time if you read this

    Yes i know i have used no punctuation sorry about that im not very good when it comes to punctuation.

    DRAGONMASTER412

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,000
    Rep Power
    10

    Default Re: Help Wanted! infinite terrain

    Quote Originally Posted by DRAGONMASTER412 View Post
    Yes i know i have used no punctuation sorry about that im not very good when it comes to punctuation.
    Knowing that, wouldn't it be a simple matter of just going back and adding punctuation? Shouldn't you make it *easier* for people to help you by making your post easier to read?

    Is this a paid project? What do you mean when you say you "couldn't get it to work"? What happened? What problem did you run into?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,149
    Rep Power
    6

    Default Re: Help Wanted! infinite terrain

    Its very weird for a programmer to say he's not good at punctuation; that can only mean you write uncompilable code too because code is FULL of punctuation.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Default Re: Help Wanted! infinite terrain

    i dont really use punctuation like normal i know how to use it in code however just when i comes to proper english (I got a D im resitting for C) i have a B in ICT

    So here is what happens:
    The world is 25 by 25 this is 1 chunk
    i have a public static int[][] chunk = new int[worldW][worldH];
    the worldW and worldH are = 25
    i also have a Queue<Block> world = new LinkedList<Block>(); this is for adding the world

    in my render as a test i have

    if(x < worldW) {
    world.add(block[x][y]);
    block[x][y].render(g);
    breakAnimation[x][y].render(g);
    if((int)Component.character.x <= chunk.length) {
    canCreate = true;
    } else {
    canCreate = false;
    }
    } else {
    world.remove();
    }

    And to call it in tick
    if(canCreate) {
    try {
    worldW += 25;
    generateLevel();
    for (int y = 0; y < block.length; y++) {
    for (int x = 0; x < block[0].length; x++) {
    world.add(block[x-25][y]);
    }
    }
    canCreate = false;
    }catch(ArrayIndexOutOfBoundsException e) {
    }
    }


    Now the problem is when my character x < -8 the world regenerates and does not increase the worldW
    nor does it add the chunk to -25 for left and then il do +25 for right
    Any help?

  5. #5
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Default Re: Help Wanted! infinite terrain

    This not a paid project it is a freeware game

  6. #6
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Default Re: Help Wanted! infinite terrain

    if you really want to see the whole code heres the entire level.java

    Java Code:
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.util.LinkedList;
    import java.util.Queue;
    import java.util.Random;
    
    public class Level {
    	public static int worldW = 25, worldH = 25; //default 250, 250 //good 500, 500 //Huge 1000, 1000
    	//public static ArrayList[] tile = new ArrayList[worldW * worldH];
    	//public static int[] chunkSize = [19 * 15];
    	public static int[][] chunk = new int[worldW][worldH];
    	public static Block[][] block = new Block[chunk.length][chunk.length];
    	public static Queue<Block> world = new LinkedList<Block>();
    	public static BlockBreakAnimation[][] breakAnimation = new BlockBreakAnimation[worldW][worldH];
    	public static int bx = 0, by = 0;
    	public static int blockBreakTimer = 0; //world sizes small 250, 250 normal 500, 500 large 1000, 1000
    	public static int blockBreakTime = 0; //default 50
    	public static int breakTimer = 0;
    	public static boolean newGame = true;
    	public static int maxStack = 64;
    	public static boolean generated = true;
    	public static boolean canCreate = false;
    	
    	public static int chunkX;
    	public static int chunkY;
    	
    	public static boolean hasChanged = false;
    	public static boolean isBreaking = false;
    
    	public boolean chunkIsLoaded;
    	public byte heightMap;
    	//width = 19
    	//height = 15
    	private int chunkCount;
    	private boolean chunkFillRight = true;
    	
    	public static void chunk() {
    		
    	}
    	
    	public Level() {
    		
    		/*public static int getWorldWidth() {
    			if(selection == 0) {
    				worldWidth = 250;
    			}
    			if(selection == 1 || selection == -1) {
    				worldWidth = 500;
    			}
    			if(selection == 2) {
    				worldWidth = 1000;
    			}
    			return width;
    		}
    		
    		public static int getWorldHeight() {
    			if(selection == 0) {
    				worldHeight = 250;
    			}
    			if(selection == 1 || selection == -1) {
    				worldHeight = 500;
    			}
    			if(selection == 2) {
    				worldHeight = 1000;
    			}
    			if(selection == 3) {
    				height = 732;
    			}
    			return height;
    		}
    		*/
    		
    		for (int x = 0; x < block.length; x++) {
    			for (int y = 0; y < block[0].length; y++) {
    				block[x][y] = new Block(new Rectangle(x * Tile.tileSize, y * Tile.tileSize, Tile.tileSize, Tile.tileSize), Tile.air, 0);
    			}
    		}
    		
    		for(int x = 0; x < breakAnimation.length; x++) {
    			for(int y = 0; y < breakAnimation[0].length; y++) {
    				breakAnimation[x][y] = new BlockBreakAnimation(new Rectangle(x * Tile.tileSize + (int) Component.sX, y * Tile.tileSize + (int) Component.sY, Tile.tileSize, Tile.tileSize), Tile.air);
    			}
    		}
    		
    		if(newGame) {
    		generateLevel();
    		//loadArrays();
    		//SaveLoad.Save();
    		} else if(!newGame){
    		//SaveLoad.Load();
    		}
    }
    	
    	public static void loadArrays() {
    	}
    	
    	public void chunkGeneration() {
    		if(worldW < 10) {
    			generateLevel();
    			worldH = 256;
    		}else {
    			worldW = 160;
    			worldH = 256;
    		}
    	}
    
    	public static void generateLevel() {
    		// Generating mountains, earth, etc.
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				if(y > worldH >> 4) { // ... / 2) - OLD
    					try {
    						if(new Random().nextInt(10) > 20) {
    							if(block[x-1][y-1].id == Tile.sand) {
    								block[x][y].id = Tile.sand;
    							}
    						}
    						if(new Random().nextInt(10) > 30) {
    							if(block[x+1][y-1].id == Tile.sand) {
    								block[x][y].id = Tile.sand;
    							}
    						}
    						if(block[x][y-1].id == Tile.sand) {
    							block[x][y].id = Tile.sand;
    							block[x][y+1].id = Tile.sand;
    							block[x-1][y].id = Tile.sand;
    							block[x+1][y].id = Tile.sand;
    							block[x+2][y].id = Tile.sand;
    							block[x+2][y+2].id = Tile.sand;
    						}
    					}catch (Exception e) {
    						
    					}
    					if(new Random().nextInt(100) < 2) {
    						try {
    						block[x][y].id = Tile.sand;
    						}catch(ArrayIndexOutOfBoundsException e) {
    							continue;
    						}
    					}
    				}
    				if (y > worldH / 16) {
    					if (new Random().nextInt(100) > 20) {
    						try {
    							if (block[x - 1][y - 1].id == Tile.dirt) {
    								block[x][y].id = Tile.dirt;
    							}
    						} catch (Exception e) {
    						}
    					}
    					if (new Random().nextInt(100) > 30) {
    						try {
    							if (block[x + 1][y - 1].id == Tile.dirt) {
    								block[x][y].id = Tile.dirt;
    							}
    						} catch (Exception e) {
    						}
    					}
    					try {
    						if (block[x][y - 1].id == Tile.dirt) {
    							block[x][y].id = Tile.dirt;
    						}
    
    					} catch (Exception e) {
    					}
    
    					if (new Random().nextInt(100) < 2) {
    						try {
    						block[x][y].id = Tile.dirt;
    						}catch(ArrayIndexOutOfBoundsException e) {
    							continue;
    						}
    					}
    				}
    			}
    		}
    
    		// Placing out stone blocks.
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				if (y > worldH / 8) {
    					if (new Random().nextInt(100) > 20) {
    						try {
    							if (block[x - 1][y - 1].id == Tile.stone) {
    								block[x][y].id = Tile.stone;
    							}
    						} catch (Exception e) {
    						}
    					}
    					if (new Random().nextInt(100) > 30) {
    						try {
    							if (block[x + 1][y - 1].id == Tile.stone) {
    								block[x][y].id = Tile.stone;
    							}
    						} catch (Exception e) {
    						}
    					}
    					try {
    						if (block[x][y - 1].id == Tile.stone) {
    							block[x][y].id = Tile.stone;
    						}
    
    					} catch (Exception e) {
    					}
    
    					if (new Random().nextInt(100) < 2) {
    						try {
    						block[x][y].id = Tile.stone;
    						}catch(ArrayIndexOutOfBoundsException e) {
    							continue;
    						}
    					}
    				}
    			}
    		}
    		// Placing out ores
    				for (int y = 0; y < block.length; y++) {
    					for (int x = 0; x < block[0].length; x++) {
    						if (y > worldH / 8) {
    							if (new Random().nextInt(100) > 20) {
    								try {
    									if (block[x - 1][y - 1].id == Tile.stone) {
    										block[x][y].id = Tile.stone;
    									}
    								} catch (Exception e) {
    								}
    							}
    							if (new Random().nextInt(100) > 30) {
    								try {
    									if (block[x + 1][y - 1].id == Tile.stone) {
    										block[x][y].id = Tile.stone;
    									}
    								} catch (Exception e) {
    								}
    							}
    							try {
    								if (block[x][y - 1].id == Tile.stone) {
    									block[x][y].id = Tile.stone;
    								}
    
    							} catch (Exception e) {
    							}
    							if (new Random().nextInt(90) > 40) {
    								try {
    									if (block[x + 1][y - 1].id == Tile.stone) {
    										block[x][y].id = Tile.copperOre;
    									}
    								} catch (Exception e) {
    								}
    							}
    							try {
    								if (block[x][y - 1].id == Tile.stone) {
    									block[x][y].id = Tile.stone;
    								}
    
    							} catch (Exception e) {
    							}
    							if (new Random().nextInt(80) > 50) {
    								try {
    									if (block[x + 1][y - 1].id == Tile.stone) {
    										block[x][y].id = Tile.ironOre;
    									}
    								} catch (Exception e) {
    								}
    							}
    							try {
    								if (block[x][y - 1].id == Tile.stone) {
    									block[x][y].id = Tile.stone;
    								}
    
    							} catch (Exception e) {
    							}
    							if (new Random().nextInt(65) > 60) {
    								try {
    									if (block[x + 1][y - 1].id == Tile.stone) {
    										block[x][y].id = Tile.steelOre;
    									}
    								} catch (Exception e) {
    								}
    							}
    							try {
    								if (block[x][y - 1].id == Tile.stone) {
    									block[x][y].id = Tile.stone;
    								}
    
    							} catch (Exception e) {
    							}
    							if (new Random().nextInt(63) > 60) {
    								try {
    									if (block[x + 1][y - 1].id == Tile.stone) {
    										block[x][y].id = Tile.goldOre;
    									}
    								} catch (Exception e) {
    								}
    							}
    							try {
    								if (block[x][y - 1].id == Tile.stone) {
    									block[x][y].id = Tile.stone;
    								}
    
    							} catch (Exception e) {
    							}
    							if (new Random().nextInt(62) > 60) {
    								try {
    									if (block[x + 1][y - 1].id == Tile.stone) {
    										block[x][y].id = Tile.diamondOre;
    									}
    								} catch (Exception e) {
    								}
    							}
    							try {
    								if (block[x][y - 1].id == Tile.stone) {
    									block[x][y].id = Tile.stone;
    								}
    
    							} catch (Exception e) {
    							}
    
    							if (new Random().nextInt(100) < 2) {
    								try {
    								block[x][y].id = Tile.coalOre;
    								}catch(ArrayIndexOutOfBoundsException e) {
    									continue;
    								}
    							}
    						}
    					}
    				}
    		// placing out trees
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				try {
    					if (block[x][y + 1].id == Tile.dirt && block[x][y].id == Tile.air) {
    						if (new Random().nextInt(100) <= 9) {
    							for (int i = 0; i < new Random().nextInt(5) + 4; i++) {
    								block[x][y - i].id = Tile.log;
    							}
    						}
    					}
    				} catch (Exception e) {
    				}
    			}
    		}
    
    		// placing out leaves on top of trees!
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				try {
    					if (block[x][y + 1].id == Tile.log && block[x][y].id == Tile.air) {
    						block[x][y].id = Tile.leaves;
    					}
    				} catch (Exception e) {
    				}
    
    			}
    		}
    
    		// placing out more leaves
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				try {
    					if (block[x + 1][y].id == Tile.leaves && block[x][y].id == Tile.air && block[x][y + 1].id == Tile.air) {
    						block[x][y].id = Tile.leaves;
    					}
    				} catch (Exception e) {
    				}
    
    			}
    		}
    
    		// placing out more leaves
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				try {
    					if (block[x - 1][y].id == Tile.leaves && block[x][y].id == Tile.air && block[x][y + 1].id == Tile.air && block[x][y - 1].id == Tile.air && block[x - 3][y].id != Tile.leaves) {
    						block[x][y].id = Tile.leaves;
    					}
    				} catch (Exception e) {
    				}
    
    			}
    		}
    
    		// placing out more leaves
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				try {
    					if (block[x][y + 1].id == Tile.leaves && block[x][y].id == Tile.air && block[x][y + 1].id == Tile.leaves) {
    						block[x][y].id = Tile.leaves;
    					}
    				} catch (Exception e) {
    				}
    
    			}
    		}
    
    		// placing out more leaves
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				try {
    					if (block[x][y + 1].id == Tile.leaves && block[x][y].id == Tile.air && block[x][y + 1].id == Tile.leaves) {
    						block[x][y].id = Tile.leaves;
    					}
    				} catch (Exception e) {
    				}
    
    			}
    		}
    		
    		//placing out dungeons
    				for(int x = 0; x < worldW; x++) {
    					for(int y = 0; y < worldH; y++) {
    						try {
    						if(new Random().nextInt(3000) < 1) {
    							try {
    								if(block[x][y].id != Tile.air) {
    								if(block[x][y].id == Tile.stone) {
    								block[x][y].id = Tile.mossStone;
    								//left wall
    								block[x][y-1].id = Tile.mossStone;
    								block[x][y-2].id = Tile.mossStone;
    								block[x][y-3].id = Tile.mossStone;
    								block[x][y-4].id = Tile.mossStone;
    								block[x][y-5].id = Tile.mossStone;
    								block[x][y-6].id = Tile.mossStone;
    								//floor
    								block[x+1][y].id = Tile.mossStone;
    								block[x+2][y].id = Tile.mossStone;
    								block[x+3][y].id = Tile.mossStone;
    								block[x+4][y].id = Tile.mossStone;
    								block[x+5][y].id = Tile.mossStone;
    								block[x+6][y].id = Tile.mossStone;
    								//right wall
    								block[x+6][y-1].id = Tile.mossStone;
    								block[x+6][y-2].id = Tile.mossStone;
    								block[x+6][y-3].id = Tile.mossStone;
    								block[x+6][y-4].id = Tile.mossStone;
    								block[x+6][y-5].id = Tile.mossStone;
    								block[x+6][y-6].id = Tile.mossStone;
    								//roof
    								block[x+6][y-6].id = Tile.mossStone;
    								block[x+5][y-6].id = Tile.mossStone;
    								block[x+4][y-6].id = Tile.mossStone;
    								block[x+3][y-6].id = Tile.mossStone;
    								block[x+2][y-6].id = Tile.mossStone;
    								block[x+1][y-6].id = Tile.mossStone;
    								//empty the space
    								block[x+1][y-1].id = Tile.air;
    								block[x+2][y-1].id = Tile.air;
    								block[x+3][y-1].id = Tile.chest;
    								block[x+4][y-1].id = Tile.air;
    								block[x+5][y-1].id = Tile.air;
    								block[x+1][y-2].id = Tile.air;
    								block[x+2][y-2].id = Tile.air;
    								block[x+3][y-2].id = Tile.air;
    								block[x+4][y-2].id = Tile.air;
    								block[x+5][y-2].id = Tile.air;
    								block[x+1][y-3].id = Tile.air;
    								block[x+2][y-3].id = Tile.air;
    								block[x+3][y-3].id = Tile.air;
    								block[x+4][y-3].id = Tile.air;
    								block[x+5][y-3].id = Tile.air;
    								block[x+1][y-4].id = Tile.air;
    								block[x+2][y-4].id = Tile.air;
    								block[x+3][y-4].id = Tile.air;
    								block[x+4][y-4].id = Tile.air;
    								block[x+5][y-4].id = Tile.air;
    								block[x+1][y-5].id = Tile.air;
    								block[x+2][y-5].id = Tile.air;
    								block[x+3][y-5].id = Tile.air;
    								block[x+4][y-5].id = Tile.air;
    								block[x+5][y-5].id = Tile.air;
    
    								}
    								}
    							}catch(Exception e) {
    								
    							}
    						}
    					}catch(ArrayIndexOutOfBoundsException e) {
    						continue;
    					}
    				}
    			}
    				
    		//generate red flowers
    				for(int x = 0; x < worldW; x++) {
    					for(int y = 0; y < worldH; y++) {
    						try {
    						if(new Random().nextInt(200) < 1) {
    							try {
    								if(block[x][y].id != Tile.air) {
    								if(block[x][y-1].id == Tile.grass) {
    								block[x][y].id = Tile.redFlower;
    								}
    								}
    							}catch(Exception e) {
    								
    							}
    						}
    					}catch(ArrayIndexOutOfBoundsException e) {
    						continue;
    					}
    				}
    			}
    				
    				//generate yellow flowers
    				for(int x = 0; x < worldW; x++) {
    					for(int y = 0; y < worldH; y++) {
    						try {
    						if(new Random().nextInt(200) < 1) {
    							try {
    								if(block[x][y].id != Tile.air) {
    								if(block[x][y-1].id == Tile.grass) {
    								block[x][y].id = Tile.yellowFlower;
    								}
    								}
    							}catch(Exception e) {
    								
    							}
    						}
    					}catch(ArrayIndexOutOfBoundsException e) {
    						continue;
    					}
    				}
    			}
    				
    		//generate caves
    				for(int x = 0; x < worldW; x++) {
    					for(int y = 0; y < worldH; y++) {
    						try {
    						if(new Random().nextInt(300) < 1) {
    							try {
    								if(block[x][y].id != Tile.air) {
    								if(block[x][y].id == Tile.stone && !(block[x][y].id == Tile.mossStone) && !(block[x][y].id == Tile.chest)) {
    								block[x][y].id = Tile.air;
    								//left wall
    								block[x][y-1].id = Tile.air;
    								block[x][y-2].id = Tile.air;
    								block[x][y-3].id = Tile.air;
    								block[x][y-4].id = Tile.air;
    								block[x][y-5].id = Tile.air;
    								block[x][y-6].id = Tile.air;
    								//floor
    								block[x+1][y].id = Tile.air;
    								block[x+2][y].id = Tile.air;
    								block[x+3][y].id = Tile.air;
    								block[x+4][y].id = Tile.air;
    								block[x+5][y].id = Tile.air;
    								block[x+6][y].id = Tile.air;
    								//right wall
    								block[x+6][y-1].id = Tile.air;
    								block[x+6][y-2].id = Tile.air;
    								block[x+6][y-3].id = Tile.air;
    								block[x+6][y-4].id = Tile.air;
    								block[x+6][y-5].id = Tile.air;
    								block[x+6][y-6].id = Tile.air;
    								//roof
    								block[x+6][y-6].id = Tile.air;
    								block[x+5][y-6].id = Tile.air;
    								block[x+4][y-6].id = Tile.air;
    								block[x+3][y-6].id = Tile.air;
    								block[x+2][y-6].id = Tile.air;
    								block[x+1][y-6].id = Tile.air;
    								//empty the space
    								block[x+1][y-1].id = Tile.air;
    								block[x+2][y-1].id = Tile.air;
    								block[x+3][y-1].id = Tile.air;
    								block[x+4][y-1].id = Tile.air;
    								block[x+5][y-1].id = Tile.air;
    								block[x+1][y-2].id = Tile.air;
    								block[x+2][y-2].id = Tile.air;
    								block[x+3][y-2].id = Tile.air;
    								block[x+4][y-2].id = Tile.air;
    								block[x+5][y-2].id = Tile.air;
    								block[x+1][y-3].id = Tile.air;
    								block[x+2][y-3].id = Tile.air;
    								block[x+3][y-3].id = Tile.air;
    								block[x+4][y-3].id = Tile.air;
    								block[x+5][y-3].id = Tile.air;
    								block[x+1][y-4].id = Tile.air;
    								block[x+2][y-4].id = Tile.air;
    								block[x+3][y-4].id = Tile.air;
    								block[x+4][y-4].id = Tile.air;
    								block[x+5][y-4].id = Tile.air;
    								block[x+1][y-5].id = Tile.air;
    								block[x+2][y-5].id = Tile.air;
    								block[x+3][y-5].id = Tile.air;
    								block[x+4][y-5].id = Tile.air;
    								block[x+5][y-5].id = Tile.air;
    
    								}
    								}
    							}catch(Exception e) {
    								
    							}
    						}
    					}catch(ArrayIndexOutOfBoundsException e) {
    						continue;
    					}
    				}
    			}
    				
    		//place out cactus
    				for(int x = 0; x < worldW; x++) {
    					for(int y = 0; y < worldH; y++) {
    						try {
    						if(new Random().nextInt(100) < 1) {
    							try {
    								if(block[x][y].id == Tile.sand) {
    								block[x][y-1].id = Tile.cactus;
    								block[x][y-2].id = Tile.cactus;
    								block[x][y-3].id = Tile.cactus;
    								}
    							}catch(Exception e) {
    								
    							}
    						}
    					}catch(ArrayIndexOutOfBoundsException e) {
    						continue;
    					}
    				}
    			}
    		// Placing out grass blocks.
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				try {
    				if (block[x][y].id == Tile.dirt && block[x][y - 1].id == Tile.air) {
    					block[x][y].id = Tile.grass;
    			}}catch(ArrayIndexOutOfBoundsException e) {
    				continue;
    			}}
    		}
    		// Placing out mycelium blocks.
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				try {
    				if (block[x][y].id == Tile.dirt && block[x][y - 1].id == Tile.air){
    					block[x][y].id = Tile.mycelium;
    					//for (int i = 0; i < new Random().nextInt(5) + 4; i++) {
    						//block[x][y - i].id = Tile.mycelium;
    			}}catch(ArrayIndexOutOfBoundsException e) {
    				continue;
    			}}
    			}
    		//}
    		// Placing out bedrock blocks TEST.
    //		for (int y = 0; y < block.length; y++) {
    //			for (int x = 0; x < block[0].length; x++) {
    //				try {
    //				if (x == 0 || y == 0 || x == block.length - 0 || y == block[0].length - 500) {
    //					block[x][y].id = Tile.bedRock;
    //				}
    //				}catch(ArrayIndexOutOfBoundsException e) {
    //					continue;
    //				}
    //			}
    //		}
    		
    		//TODO GENERATING CAVES
    		  /*for (int x = 0; x < worldW; x++) { for (int y = 0; y < worldH; y++) {
    		  
    		  if (new Random().nextInt(145) < 1) { try { if (block[x][y].id == Tile.dirt) { //Checks if the tile is lit up. 
    		  for (int c = 1; c <
    		 // }
    		  (new Random().nextInt(7) + 2); c++) { //Diagnally ascending variable, breaking it into levels. 
    		  for (int a = 0; a < (c * 2) + 1; a++) { //Takes each "level" and goes right and down 
    		  try { block[x][y].id =
    		  Tile.air; //Sets lighting that of the original tile and makes it darker by 20*c. Same with the rest.
    		  block[x - c + a][y - c].id = Tile.air; block[x + c - a][y + c].id = Tile.air; 
    		  } catch (Exception
    		  e) { } //To prevent error from leaving bounds of tilemap. 
    		  }
    		  
    		  for (int b = 0; b < (c * 2) + 1; b++) { //Takes each "level" and goes left and up 
    		  try { block[x - c][y - c + b].id = Tile.air; block[x + c][y + c - b].id = Tile.air; 
    		  } catch (Exception e) { } } } } } catch
    		  (Exception e) { } } if (new Random().nextInt(75) < 1) { 
    		  try { 
    		  if(block[x][y].id == Tile.stone) { //Checks if the tile is lit up. 
    		  for (int c = 1; c < (new Random().nextInt(7) + 2); c++) { //Diagnally ascending variable, breaking it into levels. 
    		  for (int a = 0; a < (c * 2) + 1; a++) { // Takes each "level" and goes right and down 
    		  try {
    		  block[x][y].id = Tile.air; //Sets lighting that of the original tile and makes it darker by 20*c. Same with the rest.
    		  block[x - c + a][y - c].id = Tile.air; block[x + c - a][y + c].id = Tile.air; 
    		  } catch (Exception e) { } //To prevent error from leaving bounds of tilemap.
    		  }
    		  for (int b = 0; b < (c * 2) + 1; b++) { //Takes each "level" and goes left and up 
    		  try {
    		  block[x - c][y - c + b].id = Tile.air; block[x +c][y + c - b].id = Tile.air; 
    		   } catch (Exception e) { } } } } 
    		   } catch (Exception e) { } }
    		  if (new Random().nextInt(500) < 1) { 
    		 try { 
    		  if(block[x][y].id == Tile.air) { //Checks if the tile is lit up.
    		  for (int c = 1; c < (new Random().nextInt(7) + 2); c++) { //Diagnally ascending variable, breaking it into levels. 
    		  for (int a = 0; a < (c * 2) + 1; a++) { // Takes each "level" and goes right and down 
    		  try {
    		  block[x][y].id = Tile.water; //Sets lighting that of the original tile and makes it darker by 20*c. Same with the rest. 
    		  block[x - c + a][y - c].id = Tile.water; block[x + c - a][y + c].id = Tile.water; 
    		  }
    		  catch (Exception e) { } //To prevent error from leaving bounds of tilemap. 
    		  }
    		  
    		  for (int b = 0; b < (c * 2) + 1; b++) { //Takes each "level" and goes left and up 
    		  try { block[x - c][y - c + b].id = Tile.water; block[x +  c][y + c - b].id = Tile.water; 
    		  } catch (Exception e) { } } } } }
    		  catch (Exception e) { } }
    		  
    		  }
    		  
    		  for (int y = 350; y < worldH; y++) { if (new Random().nextInt(500) <
    		  1) { try { if (block[x][y].id == Tile.air) {//Checks if the tile is lit up. 
    		  for (int c = 1; c < (new Random().nextInt(7) + 2); c++) { //Diagnally ascending variable, breaking it into levels. 
    		  for (int a = 0; a < (c * 2) + 1; a++) { // Takes each "level" and goes right and down 
    		  try { block[x][y].id = Tile.lava; //Sets lighting that of the original tile and makes it darker by 20*c. Same with the rest.
    		  block[x - c + a][y - c].id = Tile.lava; block[x + c - a][y + c].id =
    		  Tile.lava; } catch (Exception e) { } //To prevent error from leaving bounds of tilemap. 
    		  }
    		  
    		  for (int b = 0; b < (c * 2) + 1; b++) { //Takes each "level" and goes left and up 
    		  try { block[x - c][y - c + b].id = Tile.lava; block[x +
    		  c][y + c - b].id = Tile.lava; } catch (Exception e) { } } } } } catch
    		  (Exception e) { } } } } */
    		 
    		  //TODO GENERATING CAVES
    
    		// Placing out Solid air blocks around level. so u cant escape!
    //		for (int y = 0; y < block.length; y++) {
    //			for (int x = 0; x < block[0].length; x++) {
    //				try {
    //				if (x == 0 || y == 0 || x == block.length - 1 || y == block[0].length - 1) {
    //					block[x][y].id = Tile.solidair;
    //				}
    //				}catch(ArrayIndexOutOfBoundsException e) {
    //					continue;
    //				}
    //			}
    //		}
    		
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    				try {
    					if(block[x][y].id == Tile.dirt)
    						block[x][y].strength = 150;
    					else if(block[x][y].id == Tile.stone)
    						block[x][y].strength = 600;
    					else block[x][y].strength = 150;
    				}catch(ArrayIndexOutOfBoundsException e) {
    					continue;
    				}
    			}
    		}
    	}
    		
    
    	public void building(int camX, int camY, int renW, int renH) {
    		if (Component.isMouseLeft || Component.isMouseRight) {
    			for (int x = (camX / Tile.tileSize); x < (camX / Tile.tileSize) + renW; x++) {
    				for (int y = (camY / Tile.tileSize); y < (camY / Tile.tileSize) + renH; y++) {
    					if (x >= 0 && y >= 0 && x < worldW && y < worldH) {
    						try {
    						if (block[x][y].contains(new Point((Component.mse.x / Component.pixelSize) + (int) Component.sX, (Component.mse.y / Component.pixelSize) + (int) Component.sY))) {
    							int sid[] = Inventory.invBar[Inventory.selected].id;
    
    							if (Component.isMouseLeft) {
    								if(breakTimer == 0) {
    									blockBreakTimer = 1;
    								}
    								if(!hasChanged) {
    									bx = x;
    									by = y;
    									hasChanged = true;
    								}
    								
    								if (block[x][y].id != Tile.solidair) {
    									if (block[x][y].id != Tile.air) {
    										if (block[x][y].id == Tile.tnt) {
    											try {
    												block[x][y].id = Tile.air;
    												if(block[x + 1][y].id != Tile.solidair) {
    												block[x][y].id = Tile.air;
    												}
    												if(block[x + 1][y].id != Tile.solidair){
    												block[x + 1][y].id = Tile.air;
    												}
    												if(block[x][y - 1].id != Tile.solidair){
    													block[x + 1][y].id = Tile.air;
    													}
    												if(block[x][y - 1].id != Tile.solidair){
    													block[x][y - 1].id = Tile.air;
    													}
    												block[x - 1][y].id = Tile.air;
    												block[x][y + 1].id = Tile.air;
    												block[x][y - 1].id = Tile.air;
    												block[x + 1][y + 1].id = Tile.air;
    												block[x - 1][y + 1].id = Tile.air;
    												block[x + 1][y - 1].id = Tile.air;
    												block[x - 1][y - 1].id = Tile.air;
    
    											} catch (Exception e) {
    											}
    										}  /* else if (blockBreakTime <= blockBreakTimer) {
    											block[x][y].id = Tile.air;
    											Sound.blockBreak.play();
    											blockBreakTimer = 0;
    										} else {
    											blockBreakTimer++;
    										} */
    									}
    								}
    								
    								if(breakTimer >= block[x][y].strength - 1 && bx == x && by == y) {
    									//adds the broken item to ur inventory, 
    									//params: the block broke, and the amt it adds to the stack
    									if (block[x][y].id != Tile.air) {
    										addItemBar(block[x][y].id, 1);
    									}
    									block[bx][by].id = Tile.air;
    									breakAnimation[bx][by].id = Tile.air;
    									Sound.blockBreak.play();
    									blockBreakTimer = 0;
    								} else {
    									hasChanged = false;
    								}
    								if(bx == x && by == y) {
    									breakBlock(x, y);
    								} else {
    									bx = 0;
    									by = 0;
    								}
    							} else if (Component.isMouseRight) {
    								if(Inventory.isOpen && Inventory.holdingID == block[x][y].id) {
    									Inventory.invBag[Inventory.selected].stack /= 2;
    								}
    								if(Inventory.isOpen && Inventory.holdingID == block[x][y].id) {
    									Inventory.invWorkBench[Inventory.selected].stack /= 2;
    								}
    								if (Inventory.invBar[Inventory.selected].stack <= 0) {
    									sid = Tile.air;
    									Inventory.invBar[Inventory.selected].id = Tile.air;
    									Inventory.invBar[Inventory.selected].stack = 0;
    								}
    								if(block[x][y].id == Tile.craftingTable) {
    									Inventory.isWorkBenchOpen = true;
    									Inventory.isOpen = true;
    								}
    								if (block[x][y].id == Tile.air || block[x][y].id == Tile.lava || block[x][y].id == Tile.water || block[x][y].id == Tile.fire || block[x][y].id == Tile.underLava || block[x][y].id == Tile.underWater || block[x][y].id == Tile.backgroundPlanks) { // to add building block  || sid == Tile.block
    									if (sid == Tile.dirt || sid == Tile.grass || sid == Tile.log || sid == Tile.stone || sid == Tile.leaves || sid == Tile.tnt || sid == Tile.sand || sid == Tile.planks || sid == Tile.coalOre || sid == Tile.copperOre || sid == Tile.ironOre || sid == Tile.steelOre || sid == Tile.goldOre || sid == Tile.diamondOre || sid == Tile.water || sid == Tile.lava || sid == Tile.craftingTable || sid == Tile.furnaceOff || sid == Tile.furnaceOn || sid == Tile.chest || sid == Tile.snow || sid == Tile.mycelium || sid == Tile.cactus || sid == Tile.glass || sid == Tile.leftChair || sid == Tile.table || sid == Tile.rightChair || sid == Tile.ironBars || sid == Tile.door || sid == Tile.anvil || sid == Tile.redFlower || sid == Tile.yellowFlower || sid == Tile.snowBlock || sid == Tile.underWater || sid == Tile.underLava || sid == Tile.ice || sid == Tile.cobbleStone || sid == Tile.mossStone || sid == Tile.brick || sid == Tile.stoneBrick || sid == Tile.mossyStoneBrick || sid == Tile.crackedStoneBrick || sid == Tile.fire || sid == Tile.cake || sid == Tile.sapling) {
    										Inventory.invBar[Inventory.selected].stack -= 1;
    										block[x][y].id = sid;
    
    										if (block[x][y + 1].id == Tile.grass) {
    											block[x][y + 1].id = Tile.dirt;
    										}
    										if (block[x][y + 1].id == Tile.mycelium) {
    											block[x][y + 1].id = Tile.dirt;
    										}
    										if (block[x][y + 1].id == Tile.snow) {
    											block[x][y + 1].id = Tile.snowBlock;
    										}
    										if (block[x][y + 1].id == Tile.water) {
    											block[x][y + 1].id = Tile.underWater;
    										}
    										if (block[x][y + 1].id == Tile.lava) {
    											block[x][y + 1].id = Tile.underLava;
    										}
    										if (block[x][y + 1].id == Tile.water && block[x][y + 1].id == Tile.snow) {
    											block[x][y + 1].id = Tile.ice;
    										}
    										if (block[x][y + 1].id == Tile.glass) {
    											block[x][y + 1].id = Tile.backgroundGlass;
    										}
    										if (block[x][y + 1].id == Tile.planks) {
    											block[x][y + 1].id = Tile.backgroundPlanks;
    										}
    									}
    								}
    							}
    
    							break;
    						}
    						}catch(ArrayIndexOutOfBoundsException e) {
    							continue;
    					}
    				}
    				}
    			}
    		}
    	}
    	
    	//TODO INVENTORY STACKING CODE
    	public static void addItemBar(int[] tile, int stack) {
    		boolean hasTo = true;
    		for (int i = 0; i < Inventory.invBar.length; i++) {
    			if (Inventory.invBar[i].id == tile && tile != Tile.air) {
    				System.out.println("1");
    				Inventory.invBar[i].stack += stack;
    				hasTo = false;
    				return;
    			} else if (Inventory.invBar[i].id == Tile.air) {
    				System.out.println("3");
    				Inventory.invBar[i].id = tile;
    				Inventory.invBar[i].stack += stack;
    				hasTo = false;
    				return;
    			}
    		}			
    		if (hasTo) {
    			addItemBag(tile, stack);
    		}
    	}
    
    	public static void addItemBag(int[] tile, int stack) {
    		for (int i = 0; i < Inventory.invBag.length; i++) {
    			if (Inventory.invBag[i].id == tile && tile != Tile.air) {
    				System.out.println("2");
    				Inventory.invBag[i].stack += stack;
    				return;
    			} else if (Inventory.invBag[i].id == Tile.air) {
    				System.out.println("4");
    				Inventory.invBag[i].id = tile;
    				Inventory.invBag[i].stack += stack;
    				return;
    			}
    		}
    	}
    	
    	public void breakBlock(int x, int y) {
    		if(block[x][y].id == Tile.dirt) {
    			block[x][y].strength = 150; //150
    		}else if(block[x][y].id == Tile.stone) {
    			block[x][y].strength = 600; //600
    		}else if(block[x][y].id == Tile.planks) {
    			block[x][y].strength = 200; //200
    		}else block[x][y].strength = 150; //150
    		
    		if(block[x][y].id != Tile.air) {
    			isBreaking = true;
    			if(breakTimer < 5)
    				breakAnimation[x][y].id = Tile.break1;
    			if(breakTimer > block[x][y].strength / 9 && breakTimer < block[x][y].strength / 9 * 2)
    					breakAnimation[x][y].id = Tile.break2;
    			if(breakTimer > block[x][y].strength / 9 * 2 && breakTimer < block[x][y].strength / 9 * 3)
    				breakAnimation[x][y].id = Tile.break3;
    			if(breakTimer > block[x][y].strength / 9 * 3 && breakTimer < block[x][y].strength / 9 * 4)
    				breakAnimation[x][y].id = Tile.break4;
    			if(breakTimer > block[x][y].strength / 9 * 4 && breakTimer < block[x][y].strength / 9 * 5)
    				breakAnimation[x][y].id = Tile.break5;
    			if(breakTimer > block[x][y].strength / 9 * 5 && breakTimer < block[x][y].strength / 9 * 6)
    				breakAnimation[x][y].id = Tile.break6;
    			if(breakTimer > block[x][y].strength / 9 * 6 && breakTimer < block[x][y].strength / 9 * 7)
    				breakAnimation[x][y].id = Tile.break7;
    			if(breakTimer > block[x][y].strength / 9 * 7 && breakTimer < block[x][y].strength / 9 * 8)
    				breakAnimation[x][y].id = Tile.break8;
    			if(breakTimer > block[x][y].strength / 9 * 8 && breakTimer < block[x][y].strength)
    				breakAnimation[x][y].id = Tile.break9;
    			if(breakTimer > block[x][y].strength && breakTimer < block[x][y].strength)
    				breakAnimation[x][y].id = Tile.break10;
    		} else {
    			isBreaking = false;
    		}
    		if(breakTimer >= block[x][y].strength || !Component.isMouseLeft) {
    			breakTimer = 0;
    			hasChanged = false;
    		}
    		if(Component.isMouseLeft && breakTimer <= block[x][y].strength) {
    			breakTimer += 1;
    		}
    	}
    	
    	public int getBlocksBelow(int x, int y) {
    		int count = 0;
    		for (int i = y; i < worldH; i++) {
    			if (block[x][i].id != Tile.solidair) {
    				count++;
    			}
    		}
    		return count;
    	}
    
    	public int getBlocksBelowXY(int x, int y) {
    		for (int i = y; i < worldH; i++) {
    			if (block[x][y].id != Tile.solidair) {
    				return i;
    			}
    		}
    		return 0;
    	}
    	
    	public void makeSizeInfinite() {
    		if((int)Component.character.x>worldW){
    			Component.character.x = 0;
    		}
    		if((int)Component.character.x<0){
    			Component.character.x = worldW;
    		}
    		if((int)Component.character.y>worldH){
    			Component.character.y = 0;
    		}
    		if((int)Component.character.y<0){
    			Component.character.y = worldH;
    		}
    	}
    
    	public void tick(int camX, int camY, int renW, int renH) {
    		if (!Inventory.isOpen) {
    			building(camX, camY, renW, renH);
    		}
    			//makeSizeInfinite();
    		if(canCreate) {
    		try {
    		worldW += 25;
    		generateLevel();
    		for (int y = 0; y < block.length; y++) {
    			for (int x = 0; x < block[0].length; x++) {
    		world.add(block[x-25][y]);
    			}
    		}
    		canCreate = false;
    		}catch(ArrayIndexOutOfBoundsException e) {
    		}
    		}
    		
    	}
    	public void render(Graphics g, int camX, int camY, int renW, int renH) {
    		for (int x = (camX / Tile.tileSize); x < (camX / Tile.tileSize) + renW; x++) {
    			for (int y = (camY / Tile.tileSize); y < (camY / Tile.tileSize) + renH; y++) {
    				if(x >= 0 && y >= 0 && x < worldW && y < worldH) { //if (x >= 0 && y >= 0 && x < worldW && y < worldH) {
    					try {
    						if(x < worldW) {
    					world.add(block[x][y]);
    					block[x][y].render(g);
    					breakAnimation[x][y].render(g);
    					if((int)Component.character.x <= chunk.length) {
    					canCreate = true;
    					} else {
    					canCreate = false;
    					}
    					/*for (int i = 0; i < Sky.rain.toArray().length; i++) {
    						if (block[x][y].id != Tile.air && block[x][y].id != Tile.solidair) {
    							if (block[x][y].intersects(Sky.rain.get(i).rect)) {
    								g.drawImage(Tile.characterMoving, Sky.rain.get(i).x, Sky.rain.get(i).y, null);
    								Sky.rain.get(i).remove = true;
    							}
    						}
    					} */
    					
    					try {
    					if(block[x][y].id != Tile.solidair) {
    						g.setColor(new Color(0, 0, 0, Sky.light));
    						g.fillRect(block[x][y].x - camX, block[x][y].y - camY, block[x][y].width, block[x][y].height);
    					
    					}
    					}catch(ArrayIndexOutOfBoundsException e) {
    						continue;
    					}
    					//TODO NEW LIGHTING CODE
    					try {
    						if (block[x][y].id != Tile.air && block[x][y].id != Tile.leaves && block[x][y].id != Tile.solidair && block[x][y].id != Tile.log) {
    							for (int p = 0; p < 7; p++) {
    								if (block[x][y - p - 2].id != Tile.air && block[x - p - 2][y].id != Tile.air && block[x + p][y].id != Tile.air && block[x][y + p].id != Tile.air && block[x][y].id != Tile.solidair) {
    									g.setColor(new Color(0, 0, 0, 90));
    									g.fillRect(block[x][y].x - camX, block[x][y].y - camY, block[x][y].width, block[x][y].height);
    
    									int blockY = getBlocksBelowXY(x, y);
    
    									g.setColor(new Color(0, 0, 0, 90));
    									g.fillRect(block[x][blockY].x - camX, block[x][blockY].y - camY, block[x][blockY].width, block[x][blockY].height);
    								}
    							}
    						}
    					} catch (Exception e) {
    						// e.printStackTrace();
    					}
    
    					/* try { if (block[x][y].id != Tile.air && block[x][y].id !=
    					  Tile.lava && block[x][y].id != Tile.star &&
    					  block[x][y].id != Tile.leaves && block[x][y].id !=
    					  Tile.solidair) { if (block[x][y - 1].id != Tile.air &&
    					  block[x - 1][y].id != Tile.air && block[x + 1][y].id !=
    					  Tile.air && block[x][y + 1].id != Tile.air && block[x +
    					  1][y].id != Tile.star && block[x][y + 1].id != Tile.star
    					  && block[x - 1][y].id != Tile.star) { g.setColor(new
    					  Color(0, 0, 0, 50)); g.fillRect(block[x][y].x - camX,
    					  block[x][y].y - camY, block[x][y].width,
    					  block[x][y].height); }
    					  
    					 if (block[x][y].id != Tile.air && block[x][y].id !=
    					 Tile.lava && block[x][y].id != Tile.star) { if
    				     (block[x][y - 2].id != Tile.air && block[x - 1][y].id !=
    					 Tile.air && block[x + 1][y].id != Tile.air && block[x][y
    					  + 1].id != Tile.air && block[x + 1][y].id != Tile.star &&
    					  block[x][y + 1].id != Tile.star && block[x - 1][y].id !=
    					  Tile.star) { g.setColor(new Color(0, 0, 0, 100));
    					  g.fillRect(block[x][y].x - camX, block[x][y].y - camY,
    					  block[x][y].width, block[x][y].height); } } if
    					  (block[x][y].id != Tile.air && block[x][y].id !=
    					  Tile.lava && block[x][y].id != Tile.star) { if
    					  (block[x][y - 3].id != Tile.air && block[x - 1][y].id !=
    					  Tile.air && block[x + 1][y].id != Tile.air && block[x][y
    					  + 1].id != Tile.air && block[x + 1][y].id != Tile.star &&
    					  block[x][y + 1].id != Tile.star && block[x - 1][y].id !=
    					  Tile.star) { g.setColor(new Color(0, 0, 0, 150));
    					  g.fillRect(block[x][y].x - camX, block[x][y].y - camY,
    					  block[x][y].width, block[x][y].height); } } if
    					  (block[x][y].id != Tile.air && block[x][y].id !=
    					  Tile.lava && block[x][y].id != Tile.star) { if
    					  (block[x][y - 4].id != Tile.air && block[x - 1][y].id !=
    					  Tile.air && block[x + 1][y].id != Tile.air && block[x][y
    					  + 1].id != Tile.air && block[x + 1][y].id != Tile.star &&
    					  block[x][y + 1].id != Tile.star && block[x - 1][y].id !=
    					  Tile.star) { g.setColor(new Color(0, 0, 0, 200));
    					  g.fillRect(block[x][y].x - camX, block[x][y].y - camY,
    					 block[x][y].width, block[x][y].height); } } if
    					  (block[x][y].id != Tile.air && block[x][y].id !=
    					  Tile.lava && block[x][y].id != Tile.star) { if
    					  (block[x][y - 5].id != Tile.air && block[x - 1][y].id !=
    					  Tile.air && block[x + 1][y].id != Tile.air && block[x][y
    					  + 1].id != Tile.air && block[x + 1][y].id != Tile.star &&
    					  block[x][y + 1].id != Tile.star && block[x - 1][y].id !=
    					 Tile.star) { g.setColor(new Color(0, 0, 0, 255));
    					  g.fillRect(block[x][y].x - camX, block[x][y].y - camY,
    					  block[x][y].width, block[x][y].height); } } } } catch
    					  (Exception e) { e.printStackTrace(); }
    					 */
    
    					if (block[x][y].id != Tile.air && block[x][y].id != Tile.solidair && !Inventory.isOpen && !Component.inPaused) {
    						if (block[x][y].contains(new Point((Component.mse.x / Component.pixelSize) + (int) Component.sX, (Component.mse.y / Component.pixelSize) + (int) Component.sY))) {
    							g.setColor(new Color(255, 255, 255, 60));
    							g.fillRect(block[x][y].x - camX, block[x][y].y - camY, block[x][y].width, block[x][y].height);
    						}
    					}
    						} else {
    							world.remove();
    						}
    					} catch(ArrayIndexOutOfBoundsException e) {
    						continue;
    					} catch(OutOfMemoryError e) {
    						continue;
    					}
    				}
    			}
    		}
    		System.out.println("WorldW = " + worldW + " WorldH = " + worldH);
    	}
    	}
    Last edited by DRAGONMASTER412; 03-05-2014 at 11:43 PM.

  7. #7
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,002
    Rep Power
    3

    Default Re: Help Wanted! infinite terrain

    I think I like this part best:
    Java Code:
    try {
       ...
    }
    catch(OutOfMemoryError e) {
       continue;
    }
    Norm likes this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,611
    Rep Power
    25

    Default Re: Help Wanted! infinite terrain

    Isn't that what catch blocks are for: so you can ignore errors
    DRAGONMASTER412 likes this.
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Default Re: Help Wanted! infinite terrain

    i guess so i just removed that out of memory catch and it generates faster? but that still doesnt fix the problem

  10. #10
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,002
    Rep Power
    3

    Default Re: Help Wanted! infinite terrain

    I never said it should fix the problem. I only made an observation of a coding practice you might want to avoid. It reeks like Visual Basics On Error Resume Next.

    I am having some trouble fighting my way through this:

    if (block[x][y].id != Tile.air && block[x][y].id !=
    Tile.lava && block[x][y].id != Tile.star) { if
    (block[x][y - 2].id != Tile.air && block[x - 1][y].id !=
    Tile.air && block[x + 1][y].id != Tile.air && block[x][y
    + 1].id != Tile.air && block[x + 1][y].id != Tile.star &&
    block[x][y + 1].id != Tile.star && block[x - 1][y].id !=
    Tile.star) { g.setColor(new Color(0, 0, 0, 100));
    g.fillRect(block[x][y].x - camX, block[x][y].y - camY,
    block[x][y].width, block[x][y].height); } } if
    (block[x][y].id != Tile.air && block[x][y].id !=
    Tile.lava && block[x][y].id != Tile.star) { if
    (block[x][y - 3].id != Tile.air && block[x - 1][y].id !=
    Tile.air && block[x + 1][y].id != Tile.air && block[x][y
    + 1].id != Tile.air && block[x + 1][y].id != Tile.star &&
    block[x][y + 1].id != Tile.star && block[x - 1][y].id !=
    Tile.star) { g.setColor(new Color(0, 0, 0, 150));
    g.fillRect(block[x][y].x - camX, block[x][y].y - camY,
    block[x][y].width, block[x][y].height); } } if
    (block[x][y].id != Tile.air && block[x][y].id !=
    Tile.lava && block[x][y].id != Tile.star) { if
    (block[x][y - 4].id != Tile.air && block[x - 1][y].id !=
    Tile.air && block[x + 1][y].id != Tile.air && block[x][y
    + 1].id != Tile.air && block[x + 1][y].id != Tile.star &&
    block[x][y + 1].id != Tile.star && block[x - 1][y].id !=
    Tile.star) { g.setColor(new Color(0, 0, 0, 200));
    g.fillRect(block[x][y].x - camX, block[x][y].y - camY,
    block[x][y].width, block[x][y].height); } } if
    (block[x][y].id != Tile.air && block[x][y].id !=
    Tile.lava && block[x][y].id != Tile.star) { if
    (block[x][y - 5].id != Tile.air && block[x - 1][y].id !=
    Tile.air && block[x + 1][y].id != Tile.air && block[x][y
    + 1].id != Tile.air && block[x + 1][y].id != Tile.star &&
    block[x][y + 1].id != Tile.star && block[x - 1][y].id !=
    Tile.star) { g.setColor(new Color(0, 0, 0, 255));
    g.fillRect(block[x][y].x - camX, block[x][y].y - camY,
    block[x][y].width, block[x][y].height); } } } } catch
    (Exception e) { e.printStackTrace(); }

    Although every fiber in my body said no, I was tempted enough to paste this into IntelliJ and lo and behold, all the mysterious NSA code was commented out. Damn.

    I still can't make any sense of it, since I don't have Block, BlockBreakAnimation, and Tile. It is very, very hard to make any sense of your problem this way. Posting all the other classes won't help as well, since it won't reduce the complexity.

    One observation I made it that variable chunk is only used for its length, nothing else. That looks awefully redundant and probably not how you intended it to use.
    Last edited by SurfMan; 03-06-2014 at 12:08 AM.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  11. #11
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Default Re: Help Wanted! infinite terrain

    that was my old lighting code it was full with arrayindexoutofboundsexceptions the console just spammed ArrayIndexOutOfBoundsExcaeption: -1

    so i rewrite it but i commented it out just in case i want to use it in the far future

  12. #12
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Default Re: Help Wanted! infinite terrain

    to make things easier here is my block, blockbreakanimation and tile.java

    Block

    Java Code:
    import java.awt.*;
    
    public class Block extends Rectangle {
    	private static final long serialVersionUID = 1L;
    	
    	public int[] id = { -1, -1 };
    	public int strength = 50;
    
    	public Block(Rectangle size, int[] id, int strength) {
    		setBounds(size);
    		this.id = id;
    		this.strength = strength;
    	}
    
    	public void render(Graphics g) {
    		if (id != Tile.air) {
    			g.drawImage(Tile.tileset_terrain, x - (int) Component.sX, y - (int) Component.sY, x + width - (int) Component.sX, y + height - (int) Component.sY, id[0] * Tile.tileSize, id[1] * Tile.tileSize, id[0] * Tile.tileSize + Tile.tileSize, id[1] * Tile.tileSize + Tile.tileSize, null);
    	}
    }
    }
    Blockbreakanimation

    Java Code:
    import java.awt.Graphics;
    import java.awt.Rectangle;
    
    
    public class BlockBreakAnimation extends Rectangle{
    	private static final long serialVersionUID = 1L;
    	
    	public int[] id = {-1, -1};
    	
    	public BlockBreakAnimation(Rectangle size, int[] id) {
    		setBounds(size);
    		this.id = id;
    	}
    	
    	public void render(Graphics g) {
    		if(id != Tile.air) {
    		g.drawImage(Tile.tileset_terrain, x - (int) Component.sX, y - (int) Component.sY, x + width - (int) Component.sX, y + height - (int) Component.sY, id[0] * Tile.tileSize, id[1] * Tile.tileSize, id[0] * Tile.tileSize + Tile.tileSize, id[1] * Tile.tileSize + Tile.tileSize, null);
    		}
    	}
    
    }
    tile

    Java Code:
    import java.awt.image.BufferedImage;
    
    import javax.imageio.ImageIO;
    
    public class Tile {
    	public static byte tileSize = 20; //default 20
    	
    	public static byte invLength = 8; //default 8
    	public static byte invHeight = 4; //default 4
    	public static byte invCellSize = 25; //default 25
    	public static byte invCellSpace = 4; //default 4
    	public static byte invBorderSpace = 4;//default 4
    	public static byte invItemBorder = 3; //default 3
    	
    	public static int numberOfBlocks = 90;
    	
    	public static byte workBenchLength = 3;
    	public static byte workBenchHeight = 3;
    	public static byte productLength = 1;
    	public static byte productHeight = 1;
    	
    	public static byte invWorkBenchLength = 2;
    	public static byte invWorkBenchHeight = 2;
    	public static byte invProductLength = 1;
    	public static byte invProductHeight = 1;
    	
    	public static int maxMobs = 250; //default 10
    	
    		//terrain
    		// public static int[] block {x, y};
    		public static int[] testBlock = {20, 0};
    		public static int[] air = {-1, -1};
    		public static int[] dirt = {0, 0};
    		public static int[] grass = {1, 0};
    		public static int[] sand = {2, 0};
    		public static int[] stone = {3 ,0};
    		public static int[] tnt = {4 ,0};
    		public static int[] log = {5 ,0};
    		public static int[] leaves = {6 ,0};
    		public static int[] planks = {7 ,0};
    		public static int[] mycelium = {16 ,0};
    		public static int[] snow = {1 ,1};
    		public static int[] cactus = {2 ,1};
    		public static int[] glass = {3 ,1};
    		public static int[] ironBars = {7 ,1};
    		public static int[] door = {8 ,1};
    		public static int[] redFlower = {11 ,1};
    		public static int[] yellowFlower = {12 ,1};
    		public static int[] snowBlock = {13 ,1};
    		public static int[] ice = {16 ,1};
    		public static int[] cobbleStone = {17 ,1};
    		public static int[] mossStone = {18 ,1};
    		public static int[] brick = {19 ,1};
    		public static int[] sapling = {20, 1};
    		public static int[] stoneBrick = {0 ,2};
    		public static int[] mossyStoneBrick = {1 ,2};
    		public static int[] crackedStoneBrick = {2, 2};
    		public static int[] fire = {3, 2};
    		public static int[] cake = {4, 2};
    		public static int[] bedRock = {8, 2};
    		public static int[] sandStone = {9, 2};
    		
    		//block break animation
    		public static int[] break1 = {0, 9};
    		public static int[] break2 = {1, 9};
    		public static int[] break3 = {2, 9};
    		public static int[] break4 = {3, 9};
    		public static int[] break5 = {4, 9};
    		public static int[] break6 = {5, 9};
    		public static int[] break7 = {6, 9};
    		public static int[] break8 = {7, 9};
    		public static int[] break9 = {8, 9};
    		public static int[] break10 = {9, 9};
    		
    		//background Blocks
    		public static int[] backgroundPlanks = {6, 2};
    		public static int[] backgroundGlass = {7, 2};
    		
    		//Sky
    		public static int[] star = {5, 2};
    		
    		//Solid Air Blocks
    		public static int[] solidair = {9 ,1};
    		
    		// public static int[] ore {x, y};
    		//ores
    		public static int[] coalOre = {8 ,0};
    		public static int[] copperOre = {9 ,0};
    		public static int[] ironOre = {10 ,0};
    		public static int[] steelOre = {11 ,0};
    		public static int[] goldOre = {12 ,0};
    		public static int[] diamondOre = {13 ,0};
    		
    		// public static int[] tool block {x, y};
    		//tool blocks
    		public static int[] craftingTable = {17 ,0};
    		public static int[] furnaceOff = {18 ,0};
    		public static int[] furnaceOn = {19 ,0};
    		public static int[] chest = {0 ,1};
    		public static int[] anvil = {10 ,1};
    		
    		// public static int[] furniture {x, y};
    			//furniture
    		public static int[] leftChair = {4 ,1};
    		public static int[] table = {5 ,1};
    		public static int[] rightChair = {6 ,1};
    		
    		// public static int[] item {x, y};
    		//items
    		
    		// public static int[] tool {x, y};
    		//tools
    		public static int[] woodenPickaxe = {0, 10};
    		public static int[] stonePickaxe = {0, 11};
    		public static int[] copperPickaxe = {0, 12};
    		public static int[] ironPickaxe = {0, 13};
    		public static int[] steelPickaxe = {0, 14};
    		public static int[] goldPickaxe = {0, 15};
    		public static int[] diamondPickaxe = {0, 16};
    		public static int[] woodenAxe = {0, 10};
    		public static int[] stoneAxe = {0, 10};
    		public static int[] copperAxe = {0, 10};
    		public static int[] ironAxe = {0, 10};
    		public static int[] steelAxe = {0, 10};
    		public static int[] goldAxe = {0, 10};
    		public static int[] diamondAxe = {0, 10};
    		public static int[] woodenShovel = {0, 10};
    		public static int[] stoneShovel = {0, 10};
    		public static int[] copperShovel = {0, 10};
    		public static int[] ironShovel = {0, 10};
    		public static int[] steelShovel = {0, 10};
    		public static int[] goldShovel = {0, 10};
    		public static int[] diamondShovel = {0, 10};
    
    
    		
    		// public static int[] liquids {x, y};
    		//liquids
    		public static int[] water = {14, 0};
    		public static int[] lava = {15, 0};
    		public static int[] underWater = {14, 1};
    		public static int[] underLava = {15, 1};
    		
    		// public static int[] sprite {x, y};
    		//sprites
    		public static int[] character = {0, 0};
    		public static int[] character_sneaking = {0, 2};
    		public static int[] chicken = {3, 0};
    		public static int[] pig = {6, 0};
    		public static int[] zombie = {0, 0};
    		public static int[] slenderman = {3, 2};
    		public static int[] steve = {12, 2};
    
    		
    		// public static int[] icons {x, y};
    		//icons
    		//public static int[] hearts = {0, 0};
    		//public static int[] armor = {0, 1};
    			
    	//need for image to load
    		
    	//title
    	public static BufferedImage background;
    	public static BufferedImage logo;
    	public static BufferedImage crash_logo;
    	public static BufferedImage decoreo;
    
    		//bars
    	public static BufferedImage progressBar;
    		
    		//tilesets
    	public static BufferedImage tileset_terrain;
    	public static BufferedImage tileset_items;
    	public static BufferedImage tileset_sprites;
    	public static BufferedImage tileset_night_sprites;
    	public static BufferedImage tileset_icons;
    	
    	//help items
    	public static BufferedImage bWoodenPickaxe;
    	
    	//character as Image
    	public static BufferedImage characterMoving;
    	
    	//gui
    	public static BufferedImage player;
    	public static BufferedImage tile_cell;
    	public static BufferedImage tile_select;
    	
    	public static BufferedImage playersheet;
    	public static BufferedImage nightPlayersheet;
    	
    	//menus
    	public static BufferedImage inventory_screen;
    	public static BufferedImage chest_screen;
    	public static BufferedImage largeChest_screen;
    
    	//loading screen
    	public static BufferedImage loading1;
    	public static BufferedImage loading2;
    
    	
    	//weather
    	public static BufferedImage rain;
    	
    	//sky
    	public static BufferedImage dayBackground;
    	public static BufferedImage nightBackground;
    	public static BufferedImage sun_moon;
    	public static BufferedImage cloud;
    	public static BufferedImage rain_cloud;
    	
    	//underground
    	public static BufferedImage backgroundStone;
    	public static BufferedImage night_backgroundStone;
    
    	
    	//messages
    	public static BufferedImage death;
    	
    	//icons
    	public static BufferedImage heart;
    	public static BufferedImage armor;
    	public static BufferedImage heart_damage;
    	public static BufferedImage armor_damage;
    	
    	//buttons
    	public static BufferedImage selected;
    	public static BufferedImage unselected;
    	public static BufferedImage unavaliable;
    	
    	//mobile buttons
    	public static BufferedImage mine;
    	public static BufferedImage build;
    	public static BufferedImage left;
    	public static BufferedImage right;
    	public static BufferedImage inventory;
    	public static BufferedImage pause;
    	
    	public Tile(){
    		try{
    			
    			//Title
    			Tile.background = ImageIO.read((Component.class.getResourceAsStream("/titles/background.png")));
    			Tile.backgroundStone = ImageIO.read((Component.class.getResourceAsStream("/sky/backgroundStone.png")));
    			Tile.night_backgroundStone = ImageIO.read((Component.class.getResourceAsStream("/sky/night backgroundStone.png")));
    			Tile.decoreo = ImageIO.read((Component.class.getResourceAsStream("/titles/decoreo.png")));
    						
    			//menus
    			Tile.inventory_screen = ImageIO.read((Component.class.getResourceAsStream("/gui/menus/inventory.png")));
    			Tile.chest_screen = ImageIO.read((Component.class.getResourceAsStream("/gui/menus/chest.png")));
    			Tile.largeChest_screen = ImageIO.read((Component.class.getResourceAsStream("/gui/menus/large chest.png")));
    			
    			//custom skins
    			Tile.playersheet = ImageIO.read((Component.class.getResourceAsStream("/gui/char.png")));
    			Tile.nightPlayersheet = ImageIO.read((Component.class.getResourceAsStream("/gui/night char.png")));
    			
    			//tilesets
    			Tile.tileset_terrain = ImageIO.read((Component.class.getResourceAsStream("/tilesets/tileset_terrain.png")));
    			Tile.tileset_items = ImageIO.read((Component.class.getResourceAsStream("/tilesets/tileset_items.png")));
    			Tile.tileset_sprites = ImageIO.read((Component.class.getResourceAsStream("/tilesets/tileset_sprites.png")));
    			Tile.tileset_night_sprites = ImageIO.read((Component.class.getResourceAsStream("/tilesets/tileset_night_sprites.png")));
    			Tile.tileset_icons = ImageIO.read((Component.class.getResourceAsStream("/tilesets/tileset_icons.png")));
    			
    			//loading screen
    			Tile.loading1 = ImageIO.read((Component.class.getResourceAsStream("/loading/loading1.png")));
    			Tile.loading2 = ImageIO.read((Component.class.getResourceAsStream("/loading/loading2.png")));
    			
    		    //gui
    			Tile.player = ImageIO.read((Component.class.getResourceAsStream("/gui/player.png")));
    			Tile.tile_cell = ImageIO.read((Component.class.getResourceAsStream("/gui/hotBar/tile_cell.png")));
    			Tile.tile_select = ImageIO.read((Component.class.getResourceAsStream("/gui/hotBar/tile_select.png")));
    			
    			//bars
    			Tile.crash_logo = ImageIO.read((Component.class.getResourceAsStream("/gui/progressBar.gif")));
    			
    			//Logo
    			Tile.logo = ImageIO.read((Component.class.getResourceAsStream("/titles/logo.png")));
    			Tile.crash_logo = ImageIO.read((Component.class.getResourceAsStream("/titles/crash logo.png")));
    			
    			//messages
    			Tile.death = ImageIO.read((Component.class.getResourceAsStream("/gui/messages/death.png")));
    			
    			//icons
    			Tile.heart = ImageIO.read((Component.class.getResourceAsStream("/gui/icons/heart.png")));
    			Tile.armor = ImageIO.read((Component.class.getResourceAsStream("/gui/icons/armor.png")));
    			Tile.heart_damage = ImageIO.read((Component.class.getResourceAsStream("/gui/icons/heart damage.png")));
    			Tile.armor_damage = ImageIO.read((Component.class.getResourceAsStream("/gui/icons/armor damage.png")));
    			
    			//buttons
    			Tile.selected = ImageIO.read((Component.class.getResourceAsStream("/gui/buttons/selected.png")));
    			Tile.unselected = ImageIO.read((Component.class.getResourceAsStream("/gui/buttons/unselected.png")));
    			Tile.unavaliable = ImageIO.read((Component.class.getResourceAsStream("/gui/buttons/unavaliable.png")));
    			
    			//mobile buttons
    			Tile.mine = ImageIO.read((Component.class.getResourceAsStream("/gui/buttons/mine.png")));
    			Tile.build = ImageIO.read((Component.class.getResourceAsStream("/gui/buttons/build.png")));
    			Tile.left = ImageIO.read((Component.class.getResourceAsStream("/gui/buttons/left.png")));
    			Tile.right = ImageIO.read((Component.class.getResourceAsStream("/gui/buttons/right.png")));
    			Tile.inventory = ImageIO.read((Component.class.getResourceAsStream("/gui/buttons/inventory.png")));
    			Tile.pause = ImageIO.read((Component.class.getResourceAsStream("/gui/buttons/pause.png")));
    
    			
    			//sky
    			Tile.dayBackground = ImageIO.read((Component.class.getResourceAsStream("/sky/day background.png")));
    			Tile.nightBackground = ImageIO.read((Component.class.getResourceAsStream("/sky/night background.png")));
    			Tile.rain = ImageIO.read((Component.class.getResourceAsStream("/sky/rain.png")));
    			Tile.sun_moon = ImageIO.read((Component.class.getResourceAsStream("/sky/sun_moon.png")));
    			Tile.cloud = ImageIO.read((Component.class.getResourceAsStream("/sky/cloud.png")));
    			Tile.rain_cloud = ImageIO.read((Component.class.getResourceAsStream("/sky/rain cloud.png")));
    			
    			//held items
    			Tile.bWoodenPickaxe = Tile.tileset_terrain.getSubimage(0, tileSize * 10, 20, 20);
    			
    			//mobs as a image
    			Tile.characterMoving = Tile.tileset_sprites.getSubimage(0, tileSize * 2, 20, 20);
    
    			
    		}catch(Exception e) { }
    	}
    	
    	public static int[] getBlockName(int number) {
    		//blocks
    		if(number == 0)
    			return air;
    		if(number == 1)
    			return dirt;
    		if(number == 2)
    			return grass;
    		if(number == 3)
    			return sand;
    		if(number == 4)
    			return stone;
    		if(number == 5)
    			return tnt;
    		if(number == 6)
    			return log;
    		if(number == 7)
    			return leaves;
    		if(number == 8)
    			return planks;
    		if(number == 9)
    			return mycelium;
    		if(number == 10)
    			return snow;
    		if(number == 11)
    			return cactus;
    		if(number == 12)
    			return glass;
    		if(number == 13)
    			return ironBars;
    		if(number == 14)
    			return door;
    		if(number == 15)
    			return redFlower;
    		if(number == 16)
    			return yellowFlower;
    		if(number == 17)
    			return snowBlock;
    		if(number == 18)
    			return ice;
    		if(number == 19)
    			return cobbleStone;
    		if(number == 20)
    			return mossStone;
    		if(number == 21)
    			return brick;
    		if(number == 22)
    			return sapling;
    		if(number == 23)
    			return stoneBrick;
    		if(number == 24)
    			return mossyStoneBrick;
    		if(number == 25)
    			return crackedStoneBrick;
    		if(number == 26)
    			return fire;
    		if(number == 27)
    			return cake;
    		if(number == 28)
    			return bedRock;
    		if(number == 29)
    			return sandStone;
    		if(number == 30)
    			return break1;
    		if(number == 31)
    			return break2;
    		if(number == 32)
    			return break3;
    		if(number == 33)
    			return break4;
    		if(number == 34)
    			return break5;
    		if(number == 35)
    			return break6;
    		if(number == 36)
    			return break7;
    		if(number == 37)
    			return break8;
    		if(number == 38)
    			return break9;
    		if(number == 39)
    			return break10;
    		if(number == 40)
    			return backgroundPlanks;
    		if(number == 41)
    			return backgroundGlass;
    		if(number == 42)
    			return coalOre;
    		if(number == 43)
    			return copperOre;
    		if(number == 44)
    			return ironOre;
    		if(number == 45)
    			return steelOre;
    		if(number == 46)
    			return goldOre;
    		if(number == 47)
    			return diamondOre;
    		if(number == 48)
    			return craftingTable;
    		if(number == 49)
    			return furnaceOff;
    		if(number == 50)
    			return furnaceOn;
    		if(number == 51)
    			return anvil;
    		if(number == 52)
    			return chest;
    		if(number == 53)
    			return leftChair;
    		if(number == 54)
    			return rightChair;
    		if(number == 55)
    			return table;
    		if(number == 56)
    			return water;
    		if(number == 57)
    			return lava;
    		if(number == 58)
    			return underWater;
    		if(number == 59)
    			return underLava;
    		if(number == 60)
    			return star;
    		if(number == 61)
    			return solidair;
    		if(number == 62)
    			return testBlock;
    		
    		//items
    		if(number == 63)
    			return woodenPickaxe;
    		if(number == 64)
    			return stonePickaxe;
    		if(number == 65)
    			return copperPickaxe;
    		if(number == 66)
    			return ironPickaxe;
    		if(number == 67)
    			return steelPickaxe;
    		if(number == 68)
    			return goldPickaxe;
    		if(number == 69)
    			return diamondPickaxe;
    		if(number == 70)
    			return woodenAxe;
    		if(number == 71)
    			return stonePickaxe;
    		if(number == 72)
    			return copperAxe;
    		if(number == 73)
    			return ironAxe;
    		if(number == 74)
    			return steelAxe;
    		if(number == 75)
    			return goldAxe;
    		if(number == 76)
    			return diamondAxe;
    		if(number == 77)
    			return woodenShovel;
    		if(number == 78)
    			return stoneShovel;
    		if(number == 79)
    			return copperShovel;
    		if(number == 80)
    			return ironShovel;
    		if(number == 81)
    			return steelShovel;
    		if(number == 82)
    			return goldShovel;
    		if(number == 83)
    			return diamondShovel;
    		if(number == 84)
    			return character;
    		if(number == 85)
    			return character_sneaking;
    		if(number == 86)
    			return chicken;
    		if(number == 87)
    			return pig;
    		if(number == 88)
    			return zombie;
    		if(number == 89)
    			return slenderman;
    		if(number == 90)
    			return steve;
    		
    		return air;
    	}
    }
    Last edited by DRAGONMASTER412; 03-05-2014 at 11:43 PM.

  13. #13
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,611
    Rep Power
    25

    Default Re: Help Wanted! infinite terrain

    Please edit your post and wrap your code with code tags:
    [code]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my response, don't ignore it, ask a question.

  14. #14
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Default Re: Help Wanted! infinite terrain

    ok i did not know you can do that

  15. #15
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Default Re: Help Wanted! infinite terrain

    i think that makes it look really hard to read with the (code) and (/code) the () will be []

  16. #16
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,611
    Rep Power
    25

    Default Re: Help Wanted! infinite terrain

    The code from lines 323 to 506 should be replaced with 1 line of code that uses number to index into an array.
    And a couple of lines of code to range test the value in number.
    If you don't understand my response, don't ignore it, ask a question.

  17. #17
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Default Re: Help Wanted! infinite terrain

    what do you mean in my programming software that is a try for line 323 and block[x][y].id = Tile.redFlower; as line 506

  18. #18
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,611
    Rep Power
    25

    Default Re: Help Wanted! infinite terrain

    The line numbers were for the code in post#12
    Replace all those lines of code with something like this:
    Java Code:
    return someArray[number];
    If you don't understand my response, don't ignore it, ask a question.

  19. #19
    DRAGONMASTER412 is offline Creator of DGL
    Join Date
    Mar 2014
    Location
    UK
    Posts
    13
    Rep Power
    0

    Default Re: Help Wanted! infinite terrain

    ahhh i see smart but then again that code is for recognizing the blocks because without it when i save and then load all the blocks are not detected therefore its just black because the lighting

Similar Threads

  1. Java Random Terrain
    By exonaut in forum Advanced Java
    Replies: 2
    Last Post: 12-11-2013, 07:48 PM
  2. What is the standard way of making 2D terrain?
    By TacoManStan in forum New To Java
    Replies: 7
    Last Post: 09-15-2011, 01:57 PM
  3. 3D Terrain on Sphere?
    By quddusaliquddus in forum Advanced Java
    Replies: 1
    Last Post: 06-23-2009, 12:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •