Page 1 of 1

dynamic array lighting system (ver 0.4)

PostPosted: Sun Sep 11, 2011 11:18 am
by savvy
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)

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 :P

savvy

Re: dynamic array lighting system (ver 0.4)

PostPosted: Mon Sep 12, 2011 4:29 pm
by jimmynewguy
Let's say I really wanna to check this out, now let's also say I'm too lazy to implement it into something. :P Can you post a demo of it being used? Could just be some blocks with a light that floats around, just to see it in action!

Re: dynamic array lighting system (ver 0.4)

PostPosted: Tue Sep 13, 2011 8:00 pm
by savvy
Ok, heres a demo... click to place light.

as you can see however, it warps around the edges. I am going to make an edge limiting system as soon as i get a pause with college.

UPDATE: WONT UPLOAD GOD DAMNIT! ill try other browsers
UPDATE2: worked on ie, markslain: firefox doesnt like the upload system.

The code is slightly different, its box lighting instead of plus lighting in the demo. just switch the codes around. (one in the 1st post and the one in global code)

Re: dynamic array lighting system (ver 0.4)

PostPosted: Tue Sep 13, 2011 10:33 pm
by jimmynewguy
Looks and works very good savvy! :)

Re: dynamic array lighting system (ver 0.4)

PostPosted: Wed Sep 14, 2011 8:39 am
by savvy
cheers :D
This was the easiest of my obstacles when making this damn game lol

Re: dynamic array lighting system (ver 0.4)

PostPosted: Fri Oct 07, 2011 3:17 am
by EvanBlack
I liked what you did! It was pretty neat. But the only problem was that it gave everything a blue hue and clouded my images behind it. I edit your source and changed your light block to be more like light. Although, this could still use more work. I think the idea is great but it would be nice to have light color settings as well as smaller blocks and intensity settings.


Here is the edit.

Re: dynamic array lighting system (ver 0.4)

PostPosted: Fri Oct 07, 2011 1:33 pm
by lcl
Quite cool effect! Nice work!
Although, by making the light boxes littler and maybe circles it would be possible to achieve
even better light effect. :D

Re: dynamic array lighting system (ver 0.4)

PostPosted: Fri Oct 07, 2011 1:41 pm
by Jagmaster
I would definatly find use for it if it were possible to make circles that could merge the way these blocks do. But one could also draw circles with little squares as well.
I might play around with this. :D