Added destruction wall and player destruction
This commit is contained in:
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user