portal 2 still alive
This commit is contained in:
parent
2f9f4877d9
commit
07eb3ed129
17 changed files with 311 additions and 7 deletions
16
objects/portal/portal.gd
Normal file
16
objects/portal/portal.gd
Normal file
|
@ -0,0 +1,16 @@
|
|||
extends Node2D
|
||||
|
||||
@export var connected_portal: NodePath
|
||||
@onready var portal = get_node(connected_portal)
|
||||
var check_for_bodies = true
|
||||
|
||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||
if body is Player && check_for_bodies:
|
||||
body.global_position = portal.global_position
|
||||
body.launch(body.velocity * 1.25)
|
||||
portal.check_for_bodies = false
|
||||
|
||||
|
||||
func _on_area_2d_body_exited(body: Node2D) -> void:
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
check_for_bodies = true
|
1
objects/portal/portal.gd.uid
Normal file
1
objects/portal/portal.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dbrblyk7xttpj
|
67
objects/portal/portal.tscn
Normal file
67
objects/portal/portal.tscn
Normal file
|
@ -0,0 +1,67 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://cypj35yv5auuc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dbrblyk7xttpj" path="res://objects/portal/portal.gd" id="1_v7atq"]
|
||||
[ext_resource type="Texture2D" uid="uid://dtwp3ohanw2sn" path="res://assets/textures/portal/portal.png" id="2_ah4id"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_xxtm7"]
|
||||
resource_name = "spin"
|
||||
length = 0.5
|
||||
loop_mode = 1
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:rotation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 6.28319]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_0po8f"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:rotation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_6y8yo"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_0po8f"),
|
||||
&"spin": SubResource("Animation_xxtm7")
|
||||
}
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_v7atq"]
|
||||
size = Vector2(16, 16)
|
||||
|
||||
[node name="Portal" type="Node2D"]
|
||||
script = ExtResource("1_v7atq")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_ah4id")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_6y8yo")
|
||||
}
|
||||
autoplay = "spin"
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
collision_mask = 16
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("RectangleShape2D_v7atq")
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
||||
[connection signal="body_exited" from="Area2D" to="." method="_on_area_2d_body_exited"]
|
Loading…
Add table
Add a link
Reference in a new issue