From beb0b697ea016957f1034b19cacbeac63eaba662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melvin=20Wei=C3=9F?= Date: Wed, 24 Sep 2025 17:43:16 +0200 Subject: [PATCH] Added color modulated background --- bg_image.gd | 11 +++++++++++ bg_image.gd.uid | 1 + enemies/ghost/ghost.tscn | 1 + main.tscn | 5 ++++- utils/show_fps.gd | 2 +- 5 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 bg_image.gd create mode 100644 bg_image.gd.uid diff --git a/bg_image.gd b/bg_image.gd new file mode 100644 index 0000000..b30dc26 --- /dev/null +++ b/bg_image.gd @@ -0,0 +1,11 @@ +extends TextureRect + +@export var colors : Array[Color] = [Color(0.3, 1, 1) * 0.7, Color(1, 0.6, 0.6) * 0.7, Color(1, 1, 1) * 0.7] + +func _process(_delta: float) -> void: + var index : int = floor((%Player.position.angle() + PI)/ TAU * colors.size()) + var diff = (%Player.position.angle() + PI)/ TAU * colors.size() - index + self.modulate = linear_color_interpolation(colors[index], colors[(index + 1) % colors.size()], diff) + +func linear_color_interpolation(c1 : Color, c2 : Color, t : float): + return c1 + (c2 - c1) * t diff --git a/bg_image.gd.uid b/bg_image.gd.uid new file mode 100644 index 0000000..cadd464 --- /dev/null +++ b/bg_image.gd.uid @@ -0,0 +1 @@ +uid://gul4u5tw1vxk diff --git a/enemies/ghost/ghost.tscn b/enemies/ghost/ghost.tscn index 6ea39d7..93ec26f 100644 --- a/enemies/ghost/ghost.tscn +++ b/enemies/ghost/ghost.tscn @@ -37,6 +37,7 @@ script = ExtResource("1_6attn") [node name="EnemyHurtbox" parent="." node_paths=PackedStringArray("canvasItem") instance=ExtResource("2_34o1m")] max_hp = 50 canvasItem = NodePath("..") +id_block_time = 0.2 [node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyHurtbox"] scale = Vector2(6, 6) diff --git a/main.tscn b/main.tscn index b93192a..b334348 100644 --- a/main.tscn +++ b/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://cxo6bq26huau7"] +[gd_scene load_steps=16 format=3 uid="uid://cxo6bq26huau7"] [ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"] [ext_resource type="Texture2D" uid="uid://d3fpq76anm4t7" path="res://world/Background Prototype/Background prototype.png" id="3_kek77"] @@ -14,6 +14,7 @@ [ext_resource type="Script" uid="uid://cpaskpj67pnaj" path="res://enemies/boss/boss_spawner.gd" id="10_efxa6"] [ext_resource type="PackedScene" uid="uid://cqn67nwyrtq3k" path="res://ui/journal/journal.tscn" id="10_w48qg"] [ext_resource type="PackedScene" uid="uid://cpe4s6vsn0ujd" path="res://enemies/boss/boss.tscn" id="11_efxa6"] +[ext_resource type="Script" uid="uid://gul4u5tw1vxk" path="res://bg_image.gd" id="13_vivmo"] [node name="main" type="Node2D"] @@ -87,6 +88,8 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 texture = ExtResource("3_kek77") +script = ExtResource("13_vivmo") +colors = Array[Color]([Color(0, 0.6441987, 0.6693053, 1), Color(0.90588236, 0.15686275, 0.21176471, 0.60784316), Color(0.69803923, 0.69803923, 0.69803923, 1)]) [node name="BossSpawner" type="Node" parent="."] script = ExtResource("10_efxa6") diff --git a/utils/show_fps.gd b/utils/show_fps.gd index a67c61d..1961b6d 100644 --- a/utils/show_fps.gd +++ b/utils/show_fps.gd @@ -1,4 +1,4 @@ extends Label func _process(_delta): - set_text("FPS " + str(Engine.get_frames_per_second())) + set_text("FPS " + str(Engine.get_frames_per_second()) + ", ANGLE " + str(floor((%Player.position.angle() + PI) / TAU * 360)))