(Shame on you BMR, you're an English teacher, you should be able to think of better words...)
Ah, and most of the graphics/tilesets and whatnot have been done already, but there is some tweaking that needs to be done which is pretty obvious with the lighting tilesets.
Anywho, a bit of background information before I get to what I'm trying to accomplish.
I have a sample room, like so:
There are four torches, none of which are lit. When one torch is lit, I WRITE MAP BLOCK it to look like this:
The red line shows the boundary of the tiles that changed.
The second torch would look like this:
Same applies, but the blue line shows the boundary this time.
When both are lit, I get this:
The blue and red boundaries now intersect.
Because the space that each torch changes is always the same, I can map each area to a Zone for each torch or whatever light-source I want. And because the limit for Zones is pretty high, this shouldn't be a problem with larger maps, though I'm keeping maps relatively small to keep computations down.
Now, on to what I want to accomplish.
It is a pain to have to specify which tile goes where with a bunch of READ and WRITE map blocks. I was thinking if it was feasible (I'm pretty sure it's possible, but feasibility is another question) to write a script that figures out, by itself, which tile should go where.
For example, with Zone 01, the script would pretty much, in pseudo code, go:
Code:
LOOK AT TILE X, Y
LOOK AT SURROUNDING TILES
IF( SURROUNDING TILES( NW==FALSE, NN==TRUE, NE==FALSE, etc...) THEN(
WRITE Z BLOCK TO X, Y
)
LOOK AT TILE X, Y
LOOK AT SURROUNDING TILES
IF( SURROUNDING TILES( NW==FALSE, NN==TRUE, NE==FALSE, etc...) THEN(
WRITE Z BLOCK TO X, Y
)
Or something like that. Because each type of tile is only used in certain places, based on which tiles are either part of or not part of the zone, the script can then figure out which type of tile to use. For example, if a tile in a zone has the following:
NW==FALSE
NN==TRUE
NE==TRUE
WW==FALSE
EE==TRUE
SW==FALSE
SS==TRUE
SE==TRUE
Then I know I need this tile:
Which is only used on the western side of the blobs of light that light-sources generate.
Further, I can have the script check if there are any Zones above or below it that overlap. Each Zone would then have a Global Variable attached to it to check if the light source is either ON or OFF. Because the script checks if other Zones are ON or OFF, it can then figure out how to merge the two. Pretty much all of my light-border tiles have been made and can be connected in any configuration to create any shape, and because when each is used is static, the script can then figure out what the place where and when to do it.
The problem I'm having is, how do I figure out the state of the surrounding tiles without having to use a large and convoluted IF, AND, THEN statement? I've semi-gotten it working, but it's extremely messy and I can't quite figure out a simple and elegant solution, if such even exists that is.
One thing I thought of was creating another script that returns a string, something like: "01101010" which would be a representation of the block above. Problem is, I can't quite figure out how to do this.
Help, anyone? Would be very much appreciated.
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl



