dynamic array lighting system (ver 0.4)

You must understand the Game Editor concepts, before post here.

dynamic array lighting system (ver 0.4)

Postby savvy » 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)

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
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: dynamic array lighting system (ver 0.4)

Postby jimmynewguy » Mon Sep 12, 2011 4:29 pm

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!
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: dynamic array lighting system (ver 0.4)

Postby savvy » Tue Sep 13, 2011 8:00 pm

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)
Attachments
light thing.zip
DEMO
(211.24 KiB) Downloaded 186 times
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: dynamic array lighting system (ver 0.4)

Postby jimmynewguy » Tue Sep 13, 2011 10:33 pm

Looks and works very good savvy! :)
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: dynamic array lighting system (ver 0.4)

Postby savvy » Wed Sep 14, 2011 8:39 am

cheers :D
This was the easiest of my obstacles when making this damn game lol
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: dynamic array lighting system (ver 0.4)

Postby EvanBlack » Fri Oct 07, 2011 3:17 am

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.
Attachments
lights.rar
(77.49 KiB) Downloaded 189 times
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: dynamic array lighting system (ver 0.4)

Postby lcl » Fri Oct 07, 2011 1:33 pm

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
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: dynamic array lighting system (ver 0.4)

Postby Jagmaster » Fri Oct 07, 2011 1:41 pm

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
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron