dynamic array lighting system (ver 0.4)
Posted: Sun Sep 11, 2011 11:18 am
Smart array lighting...
you will have to make your own side limiters, but heres the basic script...
--how it works--
it finds the light around the source then lights it up, if the chosen point around the source is a block which the light can go through (such as 0 being air) then it starts another void command at that point, hence making it NOT go through solid objects. each time a new void is made the light value is lowered (light = lite-(lite/4)) so that the light fades out.
not sure if that was a good desc but heck, ask away! it works for me!
ARRAY[][0] is the light value in the array
ARRAY[][1] is the type value of the array (such as air, glass, stone)
why did i make this? secretly working on my own 2D minecraft with fast paced action and a whole lotta fear!
hope you too find a use for it
savvy
you will have to make your own side limiters, but heres the basic script...
--how it works--
it finds the light around the source then lights it up, if the chosen point around the source is a block which the light can go through (such as 0 being air) then it starts another void command at that point, hence making it NOT go through solid objects. each time a new void is made the light value is lowered (light = lite-(lite/4)) so that the light fades out.
not sure if that was a good desc but heck, ask away! it works for me!
ARRAY[][0] is the light value in the array
ARRAY[][1] is the type value of the array (such as air, glass, stone)
- Code: Select all
void lightup(int pos, float lite)
{
int ch,i,light;
ARRAY[pos][0]=lite;
light = lite-(lite/4);
for(i=0;i<8;i++)
{
if(i==0)ch=1;
if(i==1)ch=-1;
if(i==2)ch=17;
if(i==5)ch=-17;
if(pos+ch>=0&&pos+ch<=HIGHESTARRAYPOINT)
{
if(ARRAY[pos+ch][0] < light)
{
ARRAY[pos+ch][0]=light;
if(ARRAY[pos+ch][1]==0)lightup(pos+ch,light);
}
}
}
}
why did i make this? secretly working on my own 2D minecraft with fast paced action and a whole lotta fear!
hope you too find a use for it
savvy