Added danger

This commit is contained in:
2026-06-30 19:27:46 +03:00
parent 20e297999b
commit ab159b899d
18 changed files with 216 additions and 5 deletions
+53
View File
@@ -0,0 +1,53 @@
@tool
class_name Danger
extends ColorRect
const DAMAGE_VALUE = 50.0
const COLLISION_OFFSET = Vector2(8, 8)
var _player : Player
@onready var damage_timer : Timer = $DamageTimer
@onready var collision : CollisionShape2D = $Area2D/CollisionShape2D
func _ready() -> void:
_setup_collision()
func _physics_process(_delta: float) -> void:
if Engine.is_editor_hint():
_setup_collision()
func _setup_collision() -> void:
collision.shape.size = size - COLLISION_OFFSET
collision.position = (size)/2
func _hit_player() -> bool:
if not _player: return false
SoundManager.play_sfx_stream(SoundManager.sfx_stream_danger, global_position)
_player.deal_damage(DAMAGE_VALUE)
return true
func _on_body_entered(body: Node2D) -> void:
if not body is Player: return
_player = body
_hit_player()
damage_timer.start()
func _on_body_exited(body: Node2D) -> void:
if not body is Player: return
damage_timer.stop()
_player = null
func _on_damage_timer_timeout() -> void:
if not _hit_player():
damage_timer.stop()
+1
View File
@@ -0,0 +1 @@
uid://bol2bemjm438o
+35
View File
@@ -0,0 +1,35 @@
[gd_scene format=3 uid="uid://dxqq07mde0b4a"]
[ext_resource type="Shader" uid="uid://c58hxwayyl757" path="res://game/shaders/danger.gdshader" id="1_3ra4u"]
[ext_resource type="Script" uid="uid://bol2bemjm438o" path="res://game/entities/danger/danger.gd" id="2_oh0ew"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_jttxq"]
shader = ExtResource("1_3ra4u")
shader_parameter/palette = PackedColorArray(0.36862746, 0.99215686, 0.5529412, 1, 0.23921569, 0.23137255, 0.37254903, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
shader_parameter/palette_size = 2
shader_parameter/chance = 0.3
shader_parameter/edge_width = 10.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bhunq"]
resource_local_to_scene = true
size = Vector2(2, 2)
[node name="Danger" type="ColorRect" unique_id=554396375]
material = SubResource("ShaderMaterial_jttxq")
offset_right = 10.0
offset_bottom = 10.0
script = ExtResource("2_oh0ew")
[node name="Area2D" type="Area2D" parent="." unique_id=1925024065]
collision_layer = 4
collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=1370118603]
position = Vector2(5, 5)
shape = SubResource("RectangleShape2D_bhunq")
[node name="DamageTimer" type="Timer" parent="." unique_id=38832097]
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
[connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"]
[connection signal="timeout" from="DamageTimer" to="." method="_on_damage_timer_timeout"]
+2 -2
View File
@@ -17,8 +17,8 @@ shader = ExtResource("3_vrpsd")
shader_parameter/max_value = 0.0 shader_parameter/max_value = 0.0
shader_parameter/current_value = 0.0 shader_parameter/current_value = 0.0
shader_parameter/old_value = 0.0 shader_parameter/old_value = 0.0
shader_parameter/health_color = Color(0.36862746, 0.99215686, 0.5529412, 1) shader_parameter/health_color = Color(0.99215686, 0.36862746, 0.39215687, 1)
shader_parameter/depletion_color = Color(0.32941177, 0.6509804, 0.41568628, 1) shader_parameter/depletion_color = Color(0.654902, 0.29803923, 0.4745098, 1)
shader_parameter/restoration_color = Color(1, 1, 1, 1) shader_parameter/restoration_color = Color(1, 1, 1, 1)
shader_parameter/background_color = Color(0, 0, 0, 0) shader_parameter/background_color = Color(0, 0, 0, 0)
+5
View File
@@ -1176,6 +1176,8 @@ sources/0 = SubResource("TileSetAtlasSource_6b8cu")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_yeikn"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_yeikn"]
shader = ExtResource("4_6b8cu") shader = ExtResource("4_6b8cu")
shader_parameter/palette = PackedColorArray(0.36862746, 0.99215686, 0.5529412, 1, 0.23921569, 0.23137255, 0.37254903, 1, 0.23921569, 0.23137255, 0.37254903, 1, 0.23921569, 0.23137255, 0.37254903, 1, 0.23921569, 0.23137255, 0.37254903, 1, 0.23921569, 0.23137255, 0.37254903, 1, 0.23921569, 0.23137255, 0.37254903, 1, 0.23921569, 0.23137255, 0.37254903, 1)
shader_parameter/palette_size = 8
shader_parameter/corruption_x = 0.0 shader_parameter/corruption_x = 0.0
shader_parameter/edge_width = 50.0 shader_parameter/edge_width = 50.0
shader_parameter/screen_to_world = Projection(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) shader_parameter/screen_to_world = Projection(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
@@ -1197,6 +1199,8 @@ script = ExtResource("1_o2mui")
[node name="TileMapLayer" type="TileMapLayer" parent="." unique_id=502099522] [node name="TileMapLayer" type="TileMapLayer" parent="." unique_id=502099522]
tile_set = SubResource("TileSet_71ysb") tile_set = SubResource("TileSet_71ysb")
[node name="Dangers" type="Node2D" parent="." unique_id=608961351]
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1125559156] [node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1125559156]
[node name="LevelColorRect" type="ColorRect" parent="CanvasLayer" unique_id=739757562] [node name="LevelColorRect" type="ColorRect" parent="CanvasLayer" unique_id=739757562]
@@ -1229,6 +1233,7 @@ unique_name_in_owner = true
process_mode = 2 process_mode = 2
[node name="CorruptionTimer" type="Timer" parent="." unique_id=783383429] [node name="CorruptionTimer" type="Timer" parent="." unique_id=783383429]
wait_time = 0.5
[node name="DestructionTimer" type="Timer" parent="." unique_id=431284916] [node name="DestructionTimer" type="Timer" parent="." unique_id=431284916]
one_shot = true one_shot = true
+14 -1
View File
@@ -1,6 +1,10 @@
[gd_scene format=4 uid="uid://cuig5x5fd47hs"] [gd_scene format=4 uid="uid://cuig5x5fd47hs"]
[ext_resource type="PackedScene" uid="uid://hdnty666fw1h" path="res://game/levels/abstract_level.tscn" id="1_46m3m"] [ext_resource type="PackedScene" uid="uid://hdnty666fw1h" path="res://game/levels/abstract_level.tscn" id="1_46m3m"]
[ext_resource type="PackedScene" uid="uid://dxqq07mde0b4a" path="res://game/entities/danger/danger.tscn" id="2_yeikn"]
[sub_resource type="ViewportTexture" id="ViewportTexture_yeikn"]
viewport_path = NodePath("CanvasLayer/CodeViewport")
[node name="TestLevel" unique_id=1001045799 instance=ExtResource("1_46m3m")] [node name="TestLevel" unique_id=1001045799 instance=ExtResource("1_46m3m")]
initial_corruption_x = -500.0 initial_corruption_x = -500.0
@@ -10,4 +14,13 @@ corruption_speed = 10.0
position = Vector2(0, -38) position = Vector2(0, -38)
[node name="TileMapLayer" parent="." index="1" unique_id=502099522] [node name="TileMapLayer" parent="." index="1" unique_id=502099522]
tile_map_data = PackedByteArray("AAAMAP//AAAFAAoAAAAMAP7/AAALAAYAAAAMAP3/AAAIAAYAAAAMAPz/AAAKAAYAAAAMAPv/AAADAAYAAAAMAPr/AAAGAAYAAAAMAPn/AAABAAYAAAAMAPj/AAAIAAYAAAAMAPf/AAAFAAYAAAAMAPb/AAAIAAYAAAAMAPX/AAALAAYAAAAMAPT/AAALAAYAAAAMAPP/AAADAAYAAAAMAPL/AAACAAYAAAAMAPH/AAAFAAYAAAAMAPD/AAABAAYAAAAAAPn/AAADAAQAAAAAAPj/AAAKAAYAAAAAAPf/AAACAAYAAAAAAPb/AAADAAYAAAAAAPX/AAAJAAYAAAAAAPT/AAADAAYAAAAAAPP/AAAIAAYAAAAAAPL/AAAKAAYAAAAAAPH/AAAGAAYAAAAAAPD/AAAJAAYAAAAAAO//AAAJAAYAAAD0////AAAGAAcAAAD0//7/AAAGAAYAAAD0//3/AAABAAYAAAD0//z/AAAGAAYAAAD0//v/AAAFAAYAAAD0//r/AAAHAAYAAAD0//n/AAAHAAYAAAD0//j/AAACAAYAAAD0//f/AAAEAAYAAAD0//b/AAABAAYAAAD0//X/AAABAAYAAAD0//T/AAAIAAYAAAD0//P/AAALAAYAAAD0//L/AAAFAAYAAAD0//H/AAAGAAYAAAD0//D/AAAKAAYAA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AADAAYAAAAAAN//AAAGAAYAAAAAAN7/AAAEAAYAAAAAAN3/AAABAAYAAAAAANz/AAAKAAYAAAAAANv/AAADAAYAAAAAANr/AAACAAMAAAALAP//AAAHAAUAAAAKAP//AAAFAAUAAAAJAP//AAACAAUAAAAIAP//AAAIAAUAAAAHAP//AAAAAAUAAAAGAP//AAABAAUAAAAFAP//AAAJAAUAAAAEAP//AAALAAUAAAADAP//AAAEAAUAAAACAP//AAADAAUAAAABAP//AAAJAAUAAAAAAP//AAAJAAUAAAD/////AAAJAAUAAAD+////AAACAAUAAAD9////AAADAAUAAAD8////AAAGAAUAAAD7////AAACAAUAAAD6////AAAIAAUAAAD5////AAACAAUAAAD4////AAAHAAUAAAD3////AAACAAUAAAD2////AAAKAAUAAAD1////AAAEAAUAAAA=") tile_map_data = PackedByteArray("AAAMAP//AAAFAAoAAAAMAP7/AAALAAYAAAAMAP3/AAAIAAYAAAAMAPz/AAAKAAYAAAAMAPv/AAADAAYAAAAMAPr/AAAGAAYAAAAMAPn/AAABAAYAAAAMAPj/AAAIAAYAAAAMAPf/AAAFAAYAAAAMAPb/AAAIAAYAAAAMAPX/AAALAAYAAAAMAPT/AAALAAYAAAAMAPP/AAADAAYAAAAMAPL/AAACAAYAAAAMAPH/AAAFAAYAAAAMAPD/AAABAAYAAAAAAPn/AAADAAQAAAAAAPj/AAAKAAYAAAAAAPf/AAACAAYAAAAAAPb/AAADAAYAAAAAAPX/AAAJAAYAAAAAAPT/AAADAAYAAAAAAPP/AAAIAAYAAAAAAPL/AAAKAAYAAAAAAPH/AAAGAAYAAAAAAPD/AAAJAAYAAAAAAO//AAAJAAYAAAD0////AAAGAAcAAAD0//7/AAAGAAYAAAD0//3/AAABAAYAAAD0//z/AAAGAAYAAAD0//v/AAAFAAYAAAD0//r/AAAHAAYAAAD0//n/AAAHAAYAAAD0//j/AAACAAYAAAD0//f/AAAEAAYAAAD0//b/AAABAAYAAAD0//X/AAABAAYAAAD0//T/AAAIAAYAAAD0//P/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AAOP/AAACAAYAAAAAAOL/AAAEAAYAAAAAAOH/AAAHAAYAAAAAAOD/AAADAAYAAAAAAN//AAAGAAYAAAAAAN7/AAAEAAYAAAAAAN3/AAABAAYAAAAAANz/AAAKAAYAAAAAANv/AAADAAYAAAAAANr/AAACAAMAAAALAP//AAAHAAUAAAAKAP//AAAFAAUAAAAJAP//AAACAAUAAAAIAP//AAAIAAUAAAAHAP//AAAAAAUAAAAGAP//AAABAAUAAAAFAP//AAAJAAUAAAAEAP//AAALAAUAAAADAP//AAAEAAUAAAACAP//AAADAAUAAAABAP//AAAJAAUAAAAAAP//AAAJAAUAAAD/////AAAJAAUAAAD+////AAACAAUAAAD9////AAADAAUAAAD8////AAAGAAUAAAD7////AAACAAUAAAD6////AAAIAAUAAAD5////AAACAAUAAAD4////AAAHAAUAAAD3////AAACAAUAAAD2////AAAKAAUAAAD1////AAAEAAUAAADk/+X/AAAGAAUAAADj/+X/AAAKAAUAAADi/+X/AAACAAUAAADh/+X/AAAFAAUAAADg/+X/AAAGAAUAAADf/+X/AAAKAAUAAADe/+X/AAAIAAUAAADd/+X/AAAKAAUAAADc/+X/AAAIAAUAAADb/+X/AAAEAAUAAADa/+X/AAABAAUAAADZ/+X/AAAKAAUAAADY/+X/AAAAAAUAAADX/+X/AAAGAAUAAADW/+X/AAAKAAUAAADV/+X/AAAJAAUAAADU/+X/AAABAAUAAADT/+X/AAAEAAUAAADS/+X/AAALAAUAAADR/+X/AAACAAUAAADQ/+X/AAAJAAUAAADP/+X/AAAAAAUAAADO/+X/AAAJAAUAAADN/+X/AAAAAAUAAADM/+X/AAAKAAUAAADL/+X/AAACAAUAAADK/+X/AAABAAUAAADJ/+X/AAAJAAUAAADI/+X/AAAFAAUAAADH/+X/AAAAAAEAAAAcAOX/AAAFAAUAAAAdAOX/AAACAAUAAAAeAOX/AAAEAAUAAAAfAOX/AAACAAUAAAAgAOX/AAACAAUAAAAhAOX/AAACAAUAAAAiAOX/AAAJAAUAAAAjAOX/AAAGAAUAAAAkAOX/AAAAAAUAAAAlAOX/AAAEAAUAAAAmAOX/AAAKAAUAAAAnAOX/AAAKAAUAAAAoAOX/AAAEAAUAAAApAOX/AAADAAIAAAA=")
[node name="Danger" parent="Dangers" parent_id_path=PackedInt32Array(608961351) index="0" unique_id=554396375 instance=ExtResource("2_yeikn")]
offset_left = 89.0
offset_top = -75.0
offset_right = 189.0
offset_bottom = -55.0
[node name="CodeSprite" parent="CanvasLayer" parent_id_path=PackedInt32Array(1125559156) index="1" unique_id=1152584149]
texture = SubResource("ViewportTexture_yeikn")
+1
View File
@@ -25,6 +25,7 @@ const MUSIC_BUS = "Music"
@export_group("SFX Streams", "sfx_stream") @export_group("SFX Streams", "sfx_stream")
@export var sfx_stream_corruption : AudioStream @export var sfx_stream_corruption : AudioStream
@export var sfx_stream_danger : AudioStream
@export var sfx_stream_destruction : AudioStream @export var sfx_stream_destruction : AudioStream
@export var sfx_stream_fall : AudioStream @export var sfx_stream_fall : AudioStream
@export var sfx_stream_game_over : AudioStream @export var sfx_stream_game_over : AudioStream
+2
View File
@@ -10,6 +10,7 @@
[ext_resource type="AudioStream" uid="uid://b6xkhskx5gi0w" path="res://sound/sfx/land.wav" id="6_22ptj"] [ext_resource type="AudioStream" uid="uid://b6xkhskx5gi0w" path="res://sound/sfx/land.wav" id="6_22ptj"]
[ext_resource type="AudioStream" uid="uid://dy2eudg02crrp" path="res://sound/sfx/destruction.wav" id="6_l4iry"] [ext_resource type="AudioStream" uid="uid://dy2eudg02crrp" path="res://sound/sfx/destruction.wav" id="6_l4iry"]
[ext_resource type="AudioStream" uid="uid://ellnbrkpn47a" path="res://sound/sfx/fall.wav" id="6_q7cyi"] [ext_resource type="AudioStream" uid="uid://ellnbrkpn47a" path="res://sound/sfx/fall.wav" id="6_q7cyi"]
[ext_resource type="AudioStream" uid="uid://byn27t4ualxmi" path="res://sound/sfx/danger.wav" id="6_wyfta"]
[ext_resource type="AudioStream" uid="uid://bj6ausg5hyuyg" path="res://sound/sfx/swing.wav" id="7_ab171"] [ext_resource type="AudioStream" uid="uid://bj6ausg5hyuyg" path="res://sound/sfx/swing.wav" id="7_ab171"]
[ext_resource type="AudioStream" uid="uid://33unutlwsika" path="res://sound/sfx/wall_jump.wav" id="8_22ptj"] [ext_resource type="AudioStream" uid="uid://33unutlwsika" path="res://sound/sfx/wall_jump.wav" id="8_22ptj"]
@@ -26,6 +27,7 @@ ui_stream_accept = ExtResource("2_ge1il")
ui_stream_decline = ExtResource("3_agyxs") ui_stream_decline = ExtResource("3_agyxs")
ui_stream_select = ExtResource("4_0i6kl") ui_stream_select = ExtResource("4_0i6kl")
sfx_stream_corruption = ExtResource("5_ab171") sfx_stream_corruption = ExtResource("5_ab171")
sfx_stream_danger = ExtResource("6_wyfta")
sfx_stream_destruction = ExtResource("6_l4iry") sfx_stream_destruction = ExtResource("6_l4iry")
sfx_stream_fall = ExtResource("6_q7cyi") sfx_stream_fall = ExtResource("6_q7cyi")
sfx_stream_game_over = ExtResource("6_6ll5c") sfx_stream_game_over = ExtResource("6_6ll5c")
-1
View File
@@ -12,5 +12,4 @@ void fragment() {
float dist = destruction_x - world_pos.x; float dist = destruction_x - world_pos.x;
COLOR.a = smoothstep(-edge_width, edge_width, dist); COLOR.a = smoothstep(-edge_width, edge_width, dist);
COLOR.a /= 2.0;
} }
+45
View File
@@ -0,0 +1,45 @@
shader_type canvas_item;
#include "res://game/shaders/random_color.gdshaderinc"
uniform float chance : hint_range(0.0, 1.0) = 0.3;
uniform float edge_width : hint_range(0, 100) = 8.0;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_nearest_mipmap;
void fragment() {
vec4 screen_color = texture(SCREEN_TEXTURE, SCREEN_UV);
COLOR = random_color(screen_color, UV, chance);
float dist_left = UV.x / fwidth(UV.x);
float dist_right = (1.0 - UV.x) / fwidth(UV.x);
float dist_bottom = UV.y / fwidth(UV.y);
float dist_top = (1.0 - UV.y) / fwidth(UV.y);
float pixel_dist = min(min(dist_left, dist_right), min(dist_bottom, dist_top));
float fade = clamp(pixel_dist / edge_width, 0.0, 1.0);
COLOR.a *= fade;
//vec4 tex_color = texture(TEXTURE, UV);
//
//// Расстояние до каждого края в пикселях экрана
//float dist_left = UV.x / fwidth(UV.x);
//float dist_right = (1.0 - UV.x) / fwidth(UV.x);
//float dist_bottom = UV.y / fwidth(UV.y);
//float dist_top = (1.0 - UV.y) / fwidth(UV.y);
//
//// Берём ближайший край
//float pixel_dist = min(min(dist_left, dist_right),
//min(dist_bottom, dist_top));
//
//// Плавное затухание: 0 на самой границе, 1 на расстоянии edge_width и дальше
//float fade = clamp(pixel_dist / edge_width, 0.0, 1.0);
//
//COLOR = tex_color;
//COLOR.a *= fade;
}
+1
View File
@@ -0,0 +1 @@
uid://c58hxwayyl757
+5
View File
@@ -1,5 +1,7 @@
shader_type canvas_item; shader_type canvas_item;
#include "res://game/shaders/random_color.gdshaderinc"
uniform float corruption_x = 0.0; uniform float corruption_x = 0.0;
uniform float edge_width = 50.0; uniform float edge_width = 50.0;
uniform mat4 screen_to_world; uniform mat4 screen_to_world;
@@ -19,4 +21,7 @@ void fragment() {
COLOR.rgb = mix(bw, screen_color.rgb, t); COLOR.rgb = mix(bw, screen_color.rgb, t);
COLOR.a = screen_color.a; COLOR.a = screen_color.a;
float chance = (1.0 - t)/8.0;
COLOR = random_color(COLOR, UV, chance);
} }
+21
View File
@@ -0,0 +1,21 @@
const int MAX_PALETTE_SIZE = 8;
uniform vec3 palette[MAX_PALETTE_SIZE] : source_color;
uniform int palette_size : hint_range(1, MAX_PALETTE_SIZE) = 1;
float hash(vec2 p) {
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
}
vec4 random_color(vec4 current_color, vec2 uv, float chance)
{
vec2 seed = uv * fract(TIME);
float random_value = hash(seed);
if (chance != 0.0 && random_value < chance) {
float index_rand = hash(seed + vec2(0.5, 0.5));
int index = int(index_rand * float(palette_size)) % palette_size;
current_color.rgb = palette[index];
}
return current_color;
}
@@ -0,0 +1 @@
uid://b857povoqa1cj
Binary file not shown.
+2
View File
@@ -134,6 +134,7 @@ pause={
2d_physics/layer_1="World" 2d_physics/layer_1="World"
2d_physics/layer_2="Player" 2d_physics/layer_2="Player"
2d_physics/layer_3="Danger"
[physics] [physics]
@@ -146,3 +147,4 @@ textures/canvas_textures/default_texture_filter=0
rendering_device/driver.windows="d3d12" rendering_device/driver.windows="d3d12"
renderer/rendering_method="gl_compatibility" renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility" renderer/rendering_method.mobile="gl_compatibility"
environment/defaults/default_clear_color=Color(0.19607843, 0.19215687, 0.23137255, 1)
BIN
View File
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://byn27t4ualxmi"
path="res://.godot/imported/danger.wav-62dc671214ac3333bfbe90d66b141924.sample"
[deps]
source_file="res://sound/sfx/danger.wav"
dest_files=["res://.godot/imported/danger.wav-62dc671214ac3333bfbe90d66b141924.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2