Dynamic Lighting

by Forum_account
Dynamic Lighting
An easy way to add dynamic lighting to your game.
ID:925327
 
  • Other icon sizes need a different pixel offset for shading
  • Deleting light sources should turn them off and apply first
  • I put the day-night demo's apply() into the base /light's apply(). After deleting my light source (but turning it off and applying first), then creating a new one, a fog-of-war effect happens. Took me a while, but I fixed it by making this change:
    if(s.ambient != ambient)
    // to
    if(s.ambient != lighting.ambient)

I'd imagine there's many more things that keep this from being, as BYOND's release notes would say, as intuitive as possible in all cases.

Edit: I'm trying to use this in a 16x16 world. I set up the icon generator to generate 16x16 icons. I'm not sure if that's the cause, but I'm not seeing any difference in intensity when the ambient light level is greater than 0. When I change the light source's intensity to a negative number, it ends up being darker in the center than the outside, and that's just odd.

Edit 2: It's because I changed lighting.ambient in world.New(). Changing lighting.ambient doesn't change light sources that are created later.