Added destruction wall and player destruction
This commit is contained in:
@@ -75,12 +75,7 @@ func _ready() -> void:
|
||||
sprite.hide()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if position.y > 0.0:
|
||||
velocity.x = 0.0
|
||||
move_and_slide()
|
||||
return
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if is_on_floor():
|
||||
floor_coyote_time_timer.start()
|
||||
_last_wall_normal = 0.0
|
||||
|
||||
@@ -7,6 +7,7 @@ const CORRUPTION_DAMAGE = 10.0
|
||||
|
||||
@export var initial_corruption_x := 0.0
|
||||
@export var corruption_speed := 0.0
|
||||
@export var desctruction_offset := 100.0
|
||||
|
||||
|
||||
var _corruption_x: float
|
||||
@@ -18,9 +19,14 @@ var _corruption_x: float
|
||||
@onready var health_bar : HealthBar = $%HealthBar
|
||||
|
||||
@onready var corruption_timer : Timer = $CorruptionTimer
|
||||
@onready var destruction_timer : Timer = $DestructionTimer
|
||||
@onready var death_fall_timer : Timer = $DeathFallTimer
|
||||
|
||||
@onready var level_material : ShaderMaterial = $%LevelColorRect.material
|
||||
@onready var code_material : ShaderMaterial = $%CodeSprite.material
|
||||
|
||||
@onready var camera : Camera2D = player.camera
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -37,24 +43,30 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var screen_to_world := player.camera.get_canvas_transform().affine_inverse()
|
||||
var screen_to_world := camera.get_canvas_transform().affine_inverse()
|
||||
level_material.set_shader_parameter("screen_to_world", screen_to_world)
|
||||
level_material.set_shader_parameter("corruption_x", _corruption_x)
|
||||
code_material.set_shader_parameter("screen_to_world", screen_to_world)
|
||||
code_material.set_shader_parameter("destruction_x", _corruption_x - desctruction_offset)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
_corruption_x += corruption_speed * delta
|
||||
|
||||
if player.position.x < _corruption_x:
|
||||
if not player: return
|
||||
|
||||
if player.position.x < _corruption_x - desctruction_offset:
|
||||
_destroy_player()
|
||||
elif player.position.x < _corruption_x:
|
||||
if corruption_timer.is_stopped():
|
||||
corruption_timer.start()
|
||||
else:
|
||||
corruption_timer.stop()
|
||||
|
||||
if player.position.y > 0.0:
|
||||
if death_fall_timer.is_stopped():
|
||||
death_fall_timer.start()
|
||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_fall, player.global_position)
|
||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_fall, player.global_position)
|
||||
death_fall_timer.start()
|
||||
_delete_player()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
@@ -65,6 +77,17 @@ func _input(event: InputEvent) -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
|
||||
func _destroy_player() -> void:
|
||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_destruction, player.global_position)
|
||||
_delete_player()
|
||||
|
||||
|
||||
func _delete_player() -> void:
|
||||
player.camera.reparent(self)
|
||||
destruction_timer.start()
|
||||
player.queue_free()
|
||||
|
||||
|
||||
func _show_game_over() -> void:
|
||||
get_tree().paused = true
|
||||
game_over_menu.show()
|
||||
@@ -72,6 +95,9 @@ func _show_game_over() -> void:
|
||||
|
||||
|
||||
func _on_corruption_timer_timeout() -> void:
|
||||
if not player:
|
||||
corruption_timer.stop()
|
||||
return
|
||||
player.deal_damage(CORRUPTION_DAMAGE)
|
||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_corruption, player.global_position)
|
||||
|
||||
@@ -83,3 +109,7 @@ func _on_player_dead() -> void:
|
||||
|
||||
func _on_death_fall_timer_timeout() -> void:
|
||||
_show_game_over()
|
||||
|
||||
|
||||
func _on_destruction_timer_timeout() -> void:
|
||||
_show_game_over()
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
[ext_resource type="PackedScene" uid="uid://0e3xvmn36j5b" path="res://game/menu/pause_menu.tscn" id="3_fnnmn"]
|
||||
[ext_resource type="Shader" uid="uid://brudtlwas6x66" path="res://game/shaders/glitch.gdshader" id="4_6b8cu"]
|
||||
[ext_resource type="Texture2D" uid="uid://b8rm1kxgci4l1" path="res://images/level/beams.png" id="4_pi5fd"]
|
||||
[ext_resource type="Shader" uid="uid://b6gy8a5et63t1" path="res://game/shaders/code.gdshader" id="5_8ydah"]
|
||||
[ext_resource type="PackedScene" uid="uid://b1x0tmnf7hx7h" path="res://game/hud/health_bar.tscn" id="6_x8k35"]
|
||||
[ext_resource type="PackedScene" uid="uid://cl7vqh8j2f5py" path="res://game/menu/game_over_menu.tscn" id="7_l0xih"]
|
||||
[ext_resource type="PackedScene" uid="uid://bafplnd2un011" path="res://game/effects/code.tscn" id="8_b7vts"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_6b8cu"]
|
||||
resource_name = "Beams"
|
||||
@@ -1178,6 +1180,15 @@ shader_parameter/corruption_x = 0.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)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_b7vts"]
|
||||
shader = ExtResource("5_8ydah")
|
||||
shader_parameter/destruction_x = 0.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)
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_bhunq"]
|
||||
viewport_path = NodePath("CanvasLayer/CodeViewport")
|
||||
|
||||
[node name="AbstractLevel" type="Node2D" unique_id=1001045799]
|
||||
script = ExtResource("1_o2mui")
|
||||
|
||||
@@ -1194,6 +1205,17 @@ material = SubResource("ShaderMaterial_yeikn")
|
||||
offset_right = 640.0
|
||||
offset_bottom = 360.0
|
||||
|
||||
[node name="CodeSprite" type="Sprite2D" parent="CanvasLayer" unique_id=1152584149]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource("ShaderMaterial_b7vts")
|
||||
position = Vector2(320, 180)
|
||||
texture = SubResource("ViewportTexture_bhunq")
|
||||
|
||||
[node name="CodeViewport" type="SubViewport" parent="CanvasLayer" unique_id=1708983620]
|
||||
size = Vector2i(640, 360)
|
||||
|
||||
[node name="Code" parent="CanvasLayer/CodeViewport" unique_id=946204992 instance=ExtResource("8_b7vts")]
|
||||
|
||||
[node name="HealthBar" parent="CanvasLayer" unique_id=256637218 instance=ExtResource("6_x8k35")]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2(51, 19)
|
||||
@@ -1208,9 +1230,13 @@ process_mode = 2
|
||||
|
||||
[node name="CorruptionTimer" type="Timer" parent="." unique_id=783383429]
|
||||
|
||||
[node name="DestructionTimer" type="Timer" parent="." unique_id=431284916]
|
||||
one_shot = true
|
||||
|
||||
[node name="DeathFallTimer" type="Timer" parent="." unique_id=519159888]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="dead" from="Player" to="." method="_on_player_dead"]
|
||||
[connection signal="timeout" from="CorruptionTimer" to="." method="_on_corruption_timer_timeout"]
|
||||
[connection signal="timeout" from="DestructionTimer" to="." method="_on_destruction_timer_timeout"]
|
||||
[connection signal="timeout" from="DeathFallTimer" to="." method="_on_death_fall_timer_timeout"]
|
||||
|
||||
@@ -25,6 +25,7 @@ const MUSIC_BUS = "Music"
|
||||
|
||||
@export_group("SFX Streams", "sfx_stream")
|
||||
@export var sfx_stream_corruption : AudioStream
|
||||
@export var sfx_stream_destruction : AudioStream
|
||||
@export var sfx_stream_fall : AudioStream
|
||||
@export var sfx_stream_game_over : AudioStream
|
||||
@export var sfx_stream_jump : AudioStream
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
[ext_resource type="AudioStream" uid="uid://bcc0textvn2lx" path="res://sound/sfx/jump.wav" id="5_fpnh3"]
|
||||
[ext_resource type="AudioStream" uid="uid://b6q00ggpln0k5" path="res://sound/sfx/game_over.wav" id="6_6ll5c"]
|
||||
[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://ellnbrkpn47a" path="res://sound/sfx/fall.wav" id="6_q7cyi"]
|
||||
[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"]
|
||||
@@ -25,6 +26,7 @@ ui_stream_accept = ExtResource("2_ge1il")
|
||||
ui_stream_decline = ExtResource("3_agyxs")
|
||||
ui_stream_select = ExtResource("4_0i6kl")
|
||||
sfx_stream_corruption = ExtResource("5_ab171")
|
||||
sfx_stream_destruction = ExtResource("6_l4iry")
|
||||
sfx_stream_fall = ExtResource("6_q7cyi")
|
||||
sfx_stream_game_over = ExtResource("6_6ll5c")
|
||||
sfx_stream_jump = ExtResource("5_fpnh3")
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform float destruction_x = 0.0;
|
||||
uniform float edge_width = 50.0;
|
||||
uniform mat4 screen_to_world;
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_nearest_mipmap;
|
||||
|
||||
void fragment() {
|
||||
vec4 screen_color = texture(SCREEN_TEXTURE, SCREEN_UV);
|
||||
vec4 world_pos = screen_to_world * vec4(FRAGCOORD.xy, 0.0, 1.0);
|
||||
float dist = destruction_x - world_pos.x;
|
||||
|
||||
COLOR.a = smoothstep(-edge_width, edge_width, dist);
|
||||
COLOR.a /= 2.0;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b6gy8a5et63t1
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://dy2eudg02crrp"
|
||||
path="res://.godot/imported/destruction.wav-1e79e0dc137fbd178f07dadac951523f.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sound/sfx/destruction.wav"
|
||||
dest_files=["res://.godot/imported/destruction.wav-1e79e0dc137fbd178f07dadac951523f.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
|
||||
Reference in New Issue
Block a user