update
This commit is contained in:
28
lights.gd
28
lights.gd
@@ -2,6 +2,10 @@ extends MeshInstance
|
||||
|
||||
var t = 0.0
|
||||
var mat
|
||||
var peakt = 0.0
|
||||
var peako = false
|
||||
|
||||
const dim = 0.2
|
||||
|
||||
var lights = [
|
||||
[Vector3(6,-4.5,-2.25),Vector3.ZERO],
|
||||
@@ -10,18 +14,34 @@ var lights = [
|
||||
[Vector3(10,-4.5,-8),Vector3.ZERO]
|
||||
]
|
||||
|
||||
func rcv3():
|
||||
var tcol = Color.from_hsv(randf(),rand_range(0.85,1),1.0)
|
||||
return Vector3(tcol.r,tcol.g,tcol.b)
|
||||
|
||||
func _ready():
|
||||
for light in lights:
|
||||
light[0] = to_global(light[0])
|
||||
mat = get_surface_material(1)
|
||||
for light in lights:
|
||||
light[1] = rcv3()*dim
|
||||
|
||||
func _process(delta):
|
||||
t += delta
|
||||
lights[0][1] = Vector3(1,0,0)*(sin(t*4)/2+0.5)
|
||||
lights[1][1] = Vector3(0,1,0)*(sin(t*5.123)/2+0.5)
|
||||
lights[2][1] = Vector3(0,0,1)*(sin(t*6.7)/2+0.5)
|
||||
lights[3][1] = Vector3(1,0.5,0)*(sin(t*3.141)/2+0.5)
|
||||
if !peako and $kobolds.rpeak >= 0.5 and peakt >= 0.2:
|
||||
peako = true
|
||||
lights[randi()%len(lights)][1] = rcv3()
|
||||
if peako and $kobolds.rpeak <= 0.3:
|
||||
peako = false
|
||||
peakt = 0.0
|
||||
#lights[0][1] = Vector3(1,0,0)*float(cycle==0) #(sin(t*4)/2+0.5)
|
||||
#lights[1][1] = Vector3(0,1,0)*float(cycle==1) #(sin(t*5.123)/2+0.5)
|
||||
#lights[2][1] = Vector3(0,0,1)*float(cycle==2) #(sin(t*6.7)/2+0.5)
|
||||
#lights[3][1] = Vector3(1,0.5,0)*float(cycle==3) #(sin(t*3.141)/2+0.5)
|
||||
mat.set_shader_param("col1",lights[0][1])
|
||||
mat.set_shader_param("col2",lights[1][1])
|
||||
mat.set_shader_param("col3",lights[2][1])
|
||||
mat.set_shader_param("col4",lights[3][1])
|
||||
for light in lights:
|
||||
if Color(light[1].x,light[1].y,light[1].z).v > 0.2:
|
||||
light[1] *= 0.9
|
||||
peakt += delta
|
||||
|
||||
Reference in New Issue
Block a user