Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Let there be light! (https://forums.graalonline.com/forums/showthread.php?t=78943)

DustyPorViva 03-05-2008 11:12 PM

Let there be light!
 
1 Attachment(s)
A little lighting effect I made for single levels. You simply put the code in an NPC in the level or place it in a class and join it, the choice is yours really. You can have more than one light source in a level, but it's not gonna do anything advanced, just merely overlaps(and when played with, you can get some nice looking effects out of it). I use it for just aesthetic reasons, not logical. Like in my screenshot I'm not using it to show light coming from a window, but just to create some nice looking effects.
I should note that even though it does a lot of looping, it only does so when you enter the level and it is not noticeable at all(at least in my experience, and I run on a pretty damn terrible computer, and in my level I'm using two).
Anyways, here's the code, and an image attachment of it in effect:
PHP Code:

//#CLIENTSIDE
function onPlayerenters() {
  
// These are tiles that light will 'pass through'... add stuff like vases(that can change 
  // blocking) here. I also have the window tiles in there... so you can have a light source
  // coming from the windows, you might want to remove that
  
temp.nonblocking={0x2AC,0x2AD,0x2BC,0x2BD,0x30C,0x30D,0x30E,0x30F,0x31C,0x31D,0x31E,0x31F};
  
temp.opacity=.5// how opaque the shadow will be
  
temp.checks=300// how many checks to perform, careful not to exceed limit loop

  // NOTHING TO EDIT BELOW THIS
  
temp.seg=(pi*2)/checks;
  
temp.poly={0,0,0,64,64,64,64,0,0,0};

  for (
i=0;i<checks+1;i++) {
    for (
j=0;j<64;j+=.5) {
      if (
onwall(x-sin((i*seg))*j,y-cos((i*seg))*j)) {
        if (!(
tiles[x-sin((i*seg))*j,y-cos((i*seg))*jin nonblocking)) {
          
this.newpoly={int((x-sin((i*seg))*j)+.5),int((y-cos((i*seg))*j)+.5)};
          break;
        }
      }
    }
    
poly.add(this.newpoly[0]);
    
poly.add(this.newpoly[1]);
  }
  
poly.add(0);
  
poly.add(0);

  
showpoly(200,poly);
  
changeimgcolors(200,0,0,0,opacity);
  
changeimgvis(200,0);


Sorry for the bad screenshot... I don't know how to do a full level screenshot in Graalv5.

cbk1994 03-05-2008 11:24 PM

Very nice, though I was never a huge fan of these kinds of systems. They don't seem to fit into Graal style.

Chompy 03-05-2008 11:40 PM

Very nice Dusty ^^ :D

Clockwork 03-06-2008 12:46 AM

I like it, its just too bad that it doesn't have a z axis to affect how long the shadow should be for things like the table. :(

DustyPorViva 03-06-2008 12:49 AM

I thought about it, but that would be impossible because even though I can assign a z-axis to the light source, I wouldn't have a z-axis to compare it to when it comes to the tiles.

Rapidwolve24 03-06-2008 03:39 AM

Very nice, I think I remember you (or someone else) working on something like this.

Chompy 03-06-2008 09:19 PM

Quote:

Originally Posted by Rapidwolve24 (Post 1378156)
Very nice, I think I remember you (or someone else) working on something like this.

Yeah, Knight did :o

Inverness 03-07-2008 01:34 AM

*Eyes are vaporized by the intensity of the light*


All times are GMT +2. The time now is 11:42 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.