4.9 Traps
This commit is contained in:
parent
24fc7c2a82
commit
9db613b344
6 changed files with 86 additions and 4 deletions
|
|
@ -56,6 +56,7 @@ reset={
|
||||||
2d_physics/layer_1="world"
|
2d_physics/layer_1="world"
|
||||||
2d_physics/layer_2="player"
|
2d_physics/layer_2="player"
|
||||||
2d_physics/layer_3="deathzone"
|
2d_physics/layer_3="deathzone"
|
||||||
|
2d_physics/layer_4="trap"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
[gd_scene load_steps=11 format=3 uid="uid://cchf5vmjp6ahj"]
|
[gd_scene load_steps=13 format=3 uid="uid://cchf5vmjp6ahj"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/level.gd" id="1_84g5v"]
|
[ext_resource type="Script" path="res://scripts/level.gd" id="1_84g5v"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c7y3ileam1twx" path="res://scenes/player.tscn" id="2_d65cs"]
|
[ext_resource type="PackedScene" uid="uid://c7y3ileam1twx" path="res://scenes/player.tscn" id="2_d65cs"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dfrcbemxybvbj" path="res://scenes/jump_pad.tscn" id="3_vhvgl"]
|
[ext_resource type="PackedScene" uid="uid://dfrcbemxybvbj" path="res://scenes/jump_pad.tscn" id="3_vhvgl"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cnt3xr237kdqs" path="res://scenes/saw_trap.tscn" id="4_f5456"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cxfl4ogd53fb3" path="res://scenes/spike_ball_trap.tscn" id="5_8oo66"]
|
||||||
|
|
||||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_mvbjk"]
|
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_mvbjk"]
|
||||||
|
|
||||||
|
|
@ -59,11 +61,23 @@ texture = SubResource("GradientTexture1D_y3q5v")
|
||||||
[node name="StartPosition" type="Marker2D" parent="."]
|
[node name="StartPosition" type="Marker2D" parent="."]
|
||||||
position = Vector2(309, 135)
|
position = Vector2(309, 135)
|
||||||
|
|
||||||
[node name="JumpPad" parent="." instance=ExtResource("3_vhvgl")]
|
[node name="Objects" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="JumpPad" parent="Objects" instance=ExtResource("3_vhvgl")]
|
||||||
position = Vector2(338, 194)
|
position = Vector2(338, 194)
|
||||||
|
|
||||||
[node name="JumpPad2" parent="." instance=ExtResource("3_vhvgl")]
|
[node name="JumpPad2" parent="Objects" instance=ExtResource("3_vhvgl")]
|
||||||
position = Vector2(140, 194)
|
position = Vector2(140, 194)
|
||||||
jump_force = 500
|
jump_force = 500
|
||||||
|
|
||||||
|
[node name="Traps" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="SawTrap" parent="Traps" instance=ExtResource("4_f5456")]
|
||||||
|
position = Vector2(272, 163)
|
||||||
|
|
||||||
|
[node name="SpikeBallTrap" parent="Traps" instance=ExtResource("5_8oo66")]
|
||||||
|
position = Vector2(188, 113)
|
||||||
|
|
||||||
[connection signal="body_entered" from="Deathzone" to="." method="_on_death_zone_body_entered"]
|
[connection signal="body_entered" from="Deathzone" to="." method="_on_death_zone_body_entered"]
|
||||||
|
[connection signal="touched_player" from="Traps/SawTrap" to="." method="_on_trap_touched_player"]
|
||||||
|
[connection signal="touched_player" from="Traps/SpikeBallTrap" to="." method="_on_trap_touched_player"]
|
||||||
|
|
|
||||||
25
scenes/saw_trap.tscn
Normal file
25
scenes/saw_trap.tscn
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://cnt3xr237kdqs"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/trap.gd" id="1_23awk"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cjc6mebcg5lks" path="res://assets/textures/other/Saw.png" id="1_34mhg"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_1ysy5"]
|
||||||
|
radius = 18.0
|
||||||
|
|
||||||
|
[node name="SawTrap" type="Node2D"]
|
||||||
|
script = ExtResource("1_23awk")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("1_34mhg")
|
||||||
|
hframes = 8
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 2
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||||
|
shape = SubResource("CircleShape2D_1ysy5")
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
||||||
24
scenes/spike_ball_trap.tscn
Normal file
24
scenes/spike_ball_trap.tscn
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://cxfl4ogd53fb3"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/trap.gd" id="1_x0eb1"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dblhlyit4rs5x" path="res://assets/textures/other/Spiked Ball.png" id="2_r55mb"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_1ysy5"]
|
||||||
|
radius = 11.0
|
||||||
|
|
||||||
|
[node name="SpikeBallTrap" type="Node2D"]
|
||||||
|
script = ExtResource("1_x0eb1")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("2_r55mb")
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 2
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||||
|
shape = SubResource("CircleShape2D_1ysy5")
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
||||||
|
|
@ -13,6 +13,16 @@ func _process(delta: float) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_death_zone_body_entered(body: Node2D) -> void:
|
func _on_death_zone_body_entered(body: Node2D) -> void:
|
||||||
|
reset_player()
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
func _on_trap_touched_player() -> void:
|
||||||
|
reset_player()
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
func reset_player() -> void:
|
||||||
player.velocity = Vector2.ZERO
|
player.velocity = Vector2.ZERO
|
||||||
player.global_position = start_position.global_position
|
player.global_position = start_position.global_position
|
||||||
pass # Replace with function body.
|
pass
|
||||||
|
|
|
||||||
8
scripts/trap.gd
Normal file
8
scripts/trap.gd
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
signal touched_player
|
||||||
|
|
||||||
|
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||||
|
if body is Player:
|
||||||
|
touched_player.emit()
|
||||||
|
pass # Replace with function body.
|
||||||
Loading…
Reference in a new issue