add falling block

This commit is contained in:
pennyrigate 2023-01-13 14:52:47 -05:00
parent d6547b61d4
commit 54f0880864
20 changed files with 153 additions and 26 deletions

View file

@ -0,0 +1,18 @@
extends KinematicBody2D
var fall = false
export var fall_speed = 0.5
onready var startpos = position
func _physics_process(delta):
if fall:
position.y += fall_speed
func _on_Area2D_area_entered(area):
if area.is_in_group("player"):
fall = true
func _on_VisibilityNotifier2D_screen_exited():
position = startpos
fall = false

View file

@ -0,0 +1,38 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://graphics/falling_block/falling_block_cave.png" type="Texture" id=1]
[ext_resource path="res://objects/environment/falling_block/falling_block.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 4, 3.5 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 4, 0.5 )
[node name="FallingBlock" type="KinematicBody2D"]
script = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
position = Vector2( 4, 4.5 )
shape = SubResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
centered = false
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."]
visible = false
position = Vector2( 4, 4 )
scale = Vector2( 0.4, 0.4 )
[node name="Area2D" type="Area2D" parent="."]
visible = false
collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 4, -0.5 )
shape = SubResource( 2 )
[connection signal="screen_exited" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"]
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]