Hello there,
I’m currently working on a game that’s using squares and it is in 2D. However I want to make it a bit more realistic and maybe larger… So I got some small questions how I can make some smooth lightning that isn’t really flat and maps that aren’t at maximum 200*200(blocks not pixels, 1 block = 13pixels.)
Lightning System
For the lightning system I tried to do something with variables and just a simple lightning from above. I made the lightning with the fillRec functie and the Color functie the color is basicly (0,0,0,lightning) and in the level tick I made the lightning system like this:
[spoiler]
try { //Lightning effect in the air and contact on ground.
if(y != 0) {
if(block[x][y].id == Tile.air && block[x][y - 1].id == Tile.air || block[x][y].id != Tile.air && block[x][y - 1].id == Tile.air) {
block[x][y].lightning = block[x][y - 1].lightning;
}
}
} catch(Exception e) { }
try { //Lightning effect spreading on blocks that aren't air.
if(y != 0) {
if(block[x][y].id != Tile.air && block[x][y - 1].id != Tile.air && block[x][y - 1].lightning != 250 || block[x][y].id == Tile.air && block[x][y - 1].id != Tile.air && block[x][y - 1].lightning != 250) {
block[x][y].lightning = block[x][y - 1].lightning + 50;
}
}
} catch(Exception e) { }
[/spoiler]
As you can see, I basicly made it the if there’s a block above the block and that block isn’t equal to the id Tile.air that the lightning += 50. At my first opinion this was a great and easy idea to make a small but working lightning system. It now looks like this:
[spoiler]
http://img152.imageshack.us/img152/3415/lightningn.png
[/spoiler]
Some small things I saw and that were that the lightning on not fully squared blocks isn’t the best and the lightning isn’t really good when there’s a platform like this image:
http://img560.imageshack.us/img560/7279/23667768.png
And hints of tips are welcome, I know lightning doesn’t spread from top to bottom only but from left and right either.
Chunk System
Is there a good way to make your small chunks loop? like this small prototype map is 50*50 blocks and if you’re on block x 30 that it makes a new chunk/level on that place with a looping map not that there’s a mountain on that spot and 1 block left of it there are plains…
thanks for reading it already.
-RoseSlayer