The Daily Click ::. Forums ::. Klik Coding Help ::. Dynamic Darkness system?
 

Post Reply  Post Oekaki 
 

Posted By Message

J.C



Registered
  22/03/2013 05:18:14
Points
  118
20th September, 2015 at 20/09/2015 07:02:20 -

Hello again.

This time I'm trying to set up what I call, a dynamic lighting system where the player character is in a cave and the intent is for the screen to get darker as the player moves deeper into the cave.

Here is the setup:

I have one layer with both the "darkness" (a black screen wide square) and the "light" (an ellipse that always follows the player)

What I want to do is make it so that as the player moves away from the cave entrance, the transparency of the "darkness" decreases until it becomes a solid black color.



 
n/a

Airflow

imafirinmahlazr

Registered
  24/09/2003
Points
  -197

VIP MemberSonic SpeedSnow Cloud!Computer
20th September, 2015 at 20/09/2015 10:59:56 -

you need something that tells you if the player in inside or outside the cave. it should equal 1 or 0 depending on where the player is, call this counterA.
you also need an active object called a dimmer.

what you do is set the transparency of the black to this equation:
min(sqrt(((x_player-x_dimmer) pow 2)+((y_player-y_dimmer) pow 2)),255)*counterA

that should work good. if you need to dim faster change counterA to counterA*2.5 or something. you can slow the dimming with division instead.

Edited by Airflow

 
n/a

J.C



Registered
  22/03/2013 05:18:14
Points
  118
21st September, 2015 at 21/09/2015 04:05:31 -


Originally Posted by Airflow
you need something that tells you if the player in inside or outside the cave. it should equal 1 or 0 depending on where the player is, call this counterA.
you also need an active object called a dimmer.

what you do is set the transparency of the black to this equation:
min(sqrt(((x_player-x_dimmer) pow 2)+((y_player-y_dimmer) pow 2)),255)*counterA

that should work good. if you need to dim faster change counterA to counterA*2.5 or something. you can slow the dimming with division instead.



It seems to give me a syntax error when I pasted the equation into the effect category for darkness; set semi-transparency, set alpha blending coefficient, etc.

Which effect do I place the line of code under exactly?

Also, was counterA supposed to be a variable or just a counter?

 
n/a
   

Post Reply



 



Advertisement

Worth A Click