project_teddy/scripts/mainmenu-background.gd

63 lines
1.8 KiB
GDScript

extends Node
var ran1 = false
var ran2 = false
var idle1 = false
var idle2 = false
var switchOn = true
@onready var environment = get_node("WorldEnvironment").get_environment()
func _process(delta):
if $teddy/AnimationPlayer.is_playing() == false:
$teddy/AnimationPlayer.play("idle")
if $teddy2/AnimationPlayer.is_playing() == false:
$teddy2/AnimationPlayer.play("idle")
# await get_tree().create_timer(4).timeout
# if not ran1:
# walk_right_teddy3(delta, 18)
# if not ran2:
# walk_left_teddy4(delta, 18)
if idle1:
if $teddy3/AnimationPlayer.is_playing() == false:
$teddy3/AnimationPlayer.play("idle")
if idle2:
if $teddy4/AnimationPlayer.is_playing() == false:
$teddy4/AnimationPlayer.play("idle")
if Global.menuLightSwitch:
Global.menuLightSwitch = false
if switchOn == false:
switchOn = true
environment.background_energy_multiplier = 1
environment.ambient_light_sky_contribution = 1
$DirectionalLight3D.light_energy = 1
$eye_left.visible = false
$eye_right.visible = false
$Brown.visible = false
elif switchOn == true:
switchOn = false
environment.background_energy_multiplier = 0
environment.ambient_light_sky_contribution = 0
$DirectionalLight3D.light_energy = 0.1
$eye_left.visible = true
$eye_right.visible = true
$Brown.visible = true
func walk_right_teddy3(delta, time):
ran1 = true
while time > 0:
if $teddy3/AnimationPlayer.is_playing() == false:
$teddy3/AnimationPlayer.play("walk")
await get_tree().create_timer(0.01).timeout
time = time - delta
$teddy3.position.x -= 0.5 * delta
idle1 = true
func walk_left_teddy4(delta, time):
ran2 = true
while time > 0:
if $teddy4/AnimationPlayer.is_playing() == false:
$teddy4/AnimationPlayer.play("walk")
await get_tree().create_timer(0.01).timeout
time = time - delta
$teddy4.position.x += 0.5 * delta
idle2 = true