forked from team-sg/hero-mark-2
falling blocks can crush sg!
This commit is contained in:
parent
e541e6ea5e
commit
f8ce5ee5cf
3 changed files with 38 additions and 9 deletions
|
@ -5,10 +5,18 @@ export var fall_speed = 0.5
|
|||
onready var startpos = position
|
||||
onready var fall_timer = $FallTimer
|
||||
onready var refresh_timer = $RefreshTimer
|
||||
onready var crush_area = $CrushArea
|
||||
|
||||
func _physics_process(delta):
|
||||
#Fall
|
||||
if fall:
|
||||
position.y += fall_speed
|
||||
#Crush the player
|
||||
for area in crush_area.get_overlapping_areas():
|
||||
if area.is_in_group("player"):
|
||||
var player = area.get_parent()
|
||||
if player.is_on_floor():
|
||||
player.die()
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
if area.is_in_group("player"):
|
||||
|
|
|
@ -1,27 +1,29 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 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 )
|
||||
extents = Vector2( 4, 1 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 4, 0.5 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 3, 0.5 )
|
||||
|
||||
[node name="FallingBlock" type="KinematicBody2D"]
|
||||
collision_layer = 4
|
||||
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="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 4, 2 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."]
|
||||
visible = false
|
||||
position = Vector2( 4, 4 )
|
||||
|
@ -42,6 +44,12 @@ one_shot = true
|
|||
[node name="RefreshTimer" type="Timer" parent="."]
|
||||
wait_time = 2.0
|
||||
|
||||
[node name="CrushArea" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CrushArea"]
|
||||
position = Vector2( 4, 3.5 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[connection signal="screen_exited" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"]
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
||||
[connection signal="area_exited" from="Area2D" to="." method="_on_Area2D_area_exited"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue