Added automated mushroom glowing

This commit is contained in:
Dan 2024-06-02 17:28:38 +01:00
parent 9f224b3d69
commit cf3c8d82f1
6 changed files with 223 additions and 31 deletions

View file

@ -0,0 +1,79 @@
[gd_scene load_steps=7 format=3 uid="uid://dr3yiqpdu3iox"]
[ext_resource type="Script" path="res://entities/scripts/mushroom_glow.gd" id="1_erigl"]
[ext_resource type="Texture2D" uid="uid://b0v24ggq57237" path="res://resources/particles/smallcircle.png" id="2_o6y3e"]
[sub_resource type="Animation" id="Animation_urhq0"]
resource_name = "GlowFlicker"
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("InnerGlow:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
"update": 0,
"values": [Vector2(2, 2), Vector2(1.95, 1.95), Vector2(2, 2), Vector2(1.95, 1.95), Vector2(2, 2), Vector2(1.9375, 1.9375), Vector2(1.95, 1.95), Vector2(2, 2), Vector2(2.05, 2.05), Vector2(1.9875, 1.9875), Vector2(2, 2)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_7ivlt"]
_data = {
"GlowFlicker": SubResource("Animation_urhq0")
}
[sub_resource type="Animation" id="Animation_lk3bq"]
resource_name = "OuterGlowPulse"
length = 5.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("OuterGlow:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1, 2, 3, 3.9, 5),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
"update": 0,
"values": [Vector2(2.7, 2.7), Vector2(2.8, 2.8), Vector2(2.7, 2.7), Vector2(2.8, 2.8), Vector2(2.6, 2.6), Vector2(2.7, 2.7)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_vprws"]
_data = {
"OuterGlowPulse": SubResource("Animation_lk3bq")
}
[node name="MushroomGlow" type="Node2D"]
script = ExtResource("1_erigl")
[node name="GlowAnimation" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_7ivlt")
}
autoplay = "GlowFlicker"
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_vprws")
}
autoplay = "OuterGlowPulse"
[node name="InnerGlow" type="PointLight2D" parent="."]
scale = Vector2(2, 2)
color = Color(0.298039, 0.772549, 0.980392, 1)
energy = 1.95
shadow_enabled = true
shadow_filter = 2
shadow_filter_smooth = 7.5
texture = ExtResource("2_o6y3e")
[node name="OuterGlow" type="PointLight2D" parent="."]
scale = Vector2(2.7, 2.7)
color = Color(1, 0.811765, 0.235294, 1)
energy = 0.7
shadow_filter = 2
shadow_filter_smooth = 7.5
texture = ExtResource("2_o6y3e")

View file

@ -0,0 +1,23 @@
extends Node2D
class_name MushroomGlow
@onready var inner_glow : PointLight2D = $InnerGlow
@onready var outer_glow : PointLight2D = $OuterGlow
@onready var animation : AnimationPlayer = $GlowAnimation
@export var colour_name : String = "blue"
func _ready() -> void:
Log.pr("And dog said let their be light...")
Log.pr(position, global_position)
set_light_colour(colour_name)
animation.play("GlowFlicker")
func set_light_colour(colour : String) -> void:
if colour == "blue":
inner_glow.color = "4cc5fa"
outer_glow.color = "00b4ff"
elif colour == "yellow":
inner_glow.color = "ffcf3c"
outer_glow.color = "ffcf3c"