Hmm that could work... I'll try that.
Type: Posts; User: Bingo90
Hmm that could work... I'll try that.
Light spreading works fine when removing a wall. But it'll do absolutely nothing when placing a wall, because I haven't implemented the code yet. I tried, but I have no idea how to do this :/
There's a colon, updated the post and quoted it to make it more understandable
Okay, this is how it works (some kind of pseudocode)
void removeWall(int x, int y)
{
setWall(x,y,null);
updateLight(x,y);
}
void updateLight(int x, int y)
{
It only updates when placing or removing a wall. There are 2 arrays, a byte array (the light values) and a wall array(the walls). I told you how the light spreads.
I know, that's why I made a thread here. I don't know how I can achieve this.
When placing a wall, it should remove the light from the no longer existing light source.
When a wall is removed, updateLight is called at this position. "if (getWall(x, y) == null)" is checking if there's a wall (of course after the removal there's no wall) and if not, the light level is...
Actually the light is a 2D byte array, only the wall is a 2D Wall array.
Here's the image uploaded to this site:
2827
Here you go :)
Here's how the light updates:
2825
A update's B, C, D and E - B updates G, F, H, and want's to update A - but A's more lit than B, so B doesn't update A. A space only updates a space next to...
The darker space is not taking the light from the lighter space, it's the opposite.
Here's an example:
2824
A's light is 6 and updates B. B gets light 5. B update's C which gets light 4. C...
Right now it's not in a ring form. And the light is not additive. The light of the space is the light of the most lit space next to it (up, down, left, right not diagonally) -1. Min light is 0. And...
In the first and second pictures the lamp has a light power of 13 (max), in the third picture 6.
How far the light reaches depends on the power of the lamp, but yes you're right.
If there's no wall on that space, the lamp's light will shine through that hole and the space is lit with the lamp's light power. A space also light's all spaces next to it with the light power -1.
That's the problem. Like I said, when removing a wall tile, it calls the updateLight method, which calls it again for the spaces next to it. It should also call it when placing a wall, but it should...
Updated the code to make the light power dynamic
Well, here's an example if 2 walls are removed:
2821
When replacing one it should go back to this:
2822
Removed unneccesary code and commented the rest.
I'm trying to make a light source simulation and it almost works. It's a 2D simulation, there are wall tiles in front of a lamp. When removing a wall tile the light shines through the hole. When...