finishe pressurePlate

This commit is contained in:
Fabio 2024-08-19 03:15:07 +02:00
parent 9432084b53
commit 6913816861
6 changed files with 52 additions and 43 deletions

View file

@ -3,9 +3,9 @@
[ext_resource type="PackedScene" uid="uid://ba6afuig8bqrg" path="res://levels/LevelBase.tscn" id="1_87xn7"]
[ext_resource type="Texture2D" uid="uid://c3m4os8kteaix" path="res://textures/level01-spritesheet.png" id="2_wqskp"]
[ext_resource type="Shader" path="res://shaders/scrolling.gdshader" id="4_0x2h7"]
[ext_resource type="PackedScene" uid="uid://d0q0sfati8wk0" path="res://objects/ResizableBlock.tscn" id="5_4ggcc"]
[ext_resource type="Texture2D" uid="uid://bn7cejgxkah8o" path="res://textures/Level 01.png" id="5_4p03u"]
[ext_resource type="PackedScene" uid="uid://c6g2f7tm7iasr" path="res://objects/PressurePlate.tscn" id="7_i8kgx"]
[ext_resource type="PackedScene" uid="uid://br6fngf5208j0" path="res://objects/ResizableBlockBig.tscn" id="8_ec71m"]
[ext_resource type="PackedScene" uid="uid://c168bkledwyya" path="res://objects/Laser.tscn" id="8_gxgbn"]
[ext_resource type="PackedScene" uid="uid://dki3ft77fr3tc" path="res://objects/BreakableBlock.tscn" id="9_2ia1u"]
@ -165,19 +165,19 @@ grow_vertical = 2
texture = ExtResource("5_4p03u")
stretch_mode = 1
[node name="Block" parent="." index="6" instance=ExtResource("8_ec71m")]
position = Vector2(-65, 63)
[node name="AnimatableBody2D" parent="." index="6" instance=ExtResource("5_4ggcc")]
position = Vector2(-65, 64)
[node name="Block2" parent="." index="7" instance=ExtResource("8_ec71m")]
position = Vector2(-249, -32)
[node name="AnimatableBody2D2" parent="." index="7" instance=ExtResource("5_4ggcc")]
position = Vector2(-250, -32)
scale = Vector2(0.5, 0.5)
[node name="BreakableBlock" parent="." index="8" instance=ExtResource("9_2ia1u")]
position = Vector2(241, -47)
[node name="PressurePlate" parent="." index="9" instance=ExtResource("7_i8kgx")]
position = Vector2(-272, -32)
rotation = 1.5756
[node name="StaticBody2D" parent="." index="10" instance=ExtResource("8_gxgbn")]
[node name="StaticBody2D" parent="." index="9" instance=ExtResource("8_gxgbn")]
position = Vector2(15, 15)
[node name="PressurePlate" parent="." index="10" instance=ExtResource("7_i8kgx")]
position = Vector2(-272, -32)
rotation = 1.57987

View file

@ -13,7 +13,7 @@ region = Rect2(128.019, 31.9952, 31.9608, 31.9949)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jee2l"]
size = Vector2(6, 28.5)
[node name="StaticBody2D" type="StaticBody2D"]
[node name="Laser" type="StaticBody2D"]
collision_mask = 5
[node name="Sprite2D2" type="Sprite2D" parent="."]

View file

@ -4,7 +4,7 @@
[ext_resource type="Texture2D" uid="uid://cwf57p0osmc0w" path="res://textures/PressurePlate.png" id="1_st48m"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_c6ukx"]
size = Vector2(24, 5)
size = Vector2(24, 2)
[sub_resource type="Animation" id="Animation_fulu2"]
resource_name = "Disable"
@ -21,21 +21,6 @@ tracks/0/keys = {
"values": [1]
}
[sub_resource type="Animation" id="Animation_7ggr5"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [1]
}
[sub_resource type="Animation" id="Animation_xxdm0"]
resource_name = "Enable"
tracks/0/type = "value"
@ -51,6 +36,21 @@ tracks/0/keys = {
"values": [0]
}
[sub_resource type="Animation" id="Animation_7ggr5"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [1]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_usrhb"]
_data = {
"Disable": SubResource("Animation_fulu2"),
@ -59,13 +59,16 @@ _data = {
}
[node name="PressurePlate" type="StaticBody2D"]
collision_mask = 5
collision_layer = 32
collision_mask = 37
script = ExtResource("1_7ar3x")
[node name="Area2D" type="Area2D" parent="."]
collision_layer = 32
collision_mask = 5
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(0, 9.5)
position = Vector2(0, 11)
shape = SubResource("RectangleShape2D_c6ukx")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]

View file

@ -1,17 +1,21 @@
[gd_scene load_steps=3 format=3 uid="uid://br6fngf5208j0"]
[gd_scene load_steps=4 format=3 uid="uid://d0q0sfati8wk0"]
[ext_resource type="Script" path="res://scripts/resizable_block.gd" id="1_j40bu"]
[ext_resource type="Texture2D" uid="uid://bb8vdlgwpj8oc" path="res://textures/antivirus-block-big.png" id="3_lb374"]
[ext_resource type="Script" path="res://scripts/resizable_block.gd" id="1_ckiwc"]
[ext_resource type="Texture2D" uid="uid://bb8vdlgwpj8oc" path="res://textures/antivirus-block-big.png" id="2_i68dl"]
[node name="Block" type="StaticBody2D"]
collision_mask = 22
[sub_resource type="RectangleShape2D" id="RectangleShape2D_6cdyn"]
size = Vector2(64, 61)
[node name="AnimatableBody2D" type="AnimatableBody2D"]
collision_mask = 54
input_pickable = true
script = ExtResource("1_j40bu")
script = ExtResource("1_ckiwc")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("3_lb374")
texture = ExtResource("2_i68dl")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
polygon = PackedVector2Array(-32, -20, -28, -20, -28, -24, -24, -24, -24, -28, -20, -28, -20, -32, 20, -32, 20, -28, 24, -28, 24, -24, 28, -24, 28, -20, 32, -20, 32, 20, 28, 20, 28, 24, 24, 24, 24, 28, 20, 28, 20, 32, -20, 32, -20, 28, -24, 28, -24, 24, -28, 24, -28, 20, -32, 20)
[connection signal="input_event" from="." to="." method="_on_input_event"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_6cdyn")

View file

@ -1,6 +1,6 @@
extends StaticBody2D
@export var laser_path: NodePath # TODO
@export var laser_path: NodePath = "../StaticBody2D"
@export var required_scale: Vector2 = Vector2(1.0, 1.0)
@export var player_required_scale: Vector2 = Vector2(2.0, 2.0)
@ -14,12 +14,14 @@ func _ready():
func _on_body_entered(body: Node):
print("Wird erkannt")
if (body is StaticBody2D and body.scale >= required_scale) or (body is CharacterBody2D and body.scale >= player_required_scale):
print(body)
print(body.scale)
if (body is AnimatableBody2D and body.scale >= required_scale) or (body is CharacterBody2D and body.scale >= player_required_scale):
animation.play("Disable")
activate_plate()
func _on_body_exited(body: Node):
if (body is StaticBody2D and body.scale >= required_scale) or (body is CharacterBody2D and body.scale >= player_required_scale):
if (body is AnimatableBody2D and body.scale >= required_scale) or (body is CharacterBody2D and body.scale >= player_required_scale):
animation.play("Enable")
deactivate_plate()
@ -28,7 +30,8 @@ func activate_plate():
if not is_activated:
is_activated = true
if laser:
laser.queue_free()
laser.queue_free()
# TODO: fix error when called again
func deactivate_plate():
if is_activated:

View file

@ -1,9 +1,8 @@
extends StaticBody2D
extends AnimatableBody2D
@export var scale_up_target: Vector2 = Vector2(1.0, 1.0)
@export var scale_down_target: Vector2 = Vector2(0.5, 0.5)
@export var scale_duration: float = 0.5
@export var ui_actions: Node
@export var small_sprite = preload("res://textures/antivirus-block-small.png")
@export var large_sprite = preload("res://textures/antivirus-block-big.png")