Interactable room change
This commit is contained in:
parent
646182c5b6
commit
8f262b4ff1
|
@ -3,15 +3,20 @@ extends Node2D
|
|||
## Handles fading the screen, taking control from the player
|
||||
|
||||
@export_file("*.tscn") var scene: String
|
||||
@export var exit_point: String ## Name of node in the scne transitioning to where "who" exits
|
||||
@export var walk := true
|
||||
@export var enter_right := true
|
||||
@export var enter_time := 0.3
|
||||
@export var exit_time := 0.3
|
||||
@export var exit_point: String ## Name of node in the scne transitioning to where "who" exits
|
||||
@export var snap_to_floor := true
|
||||
|
||||
const INIT_GRACE := 0.1
|
||||
var init_grace_tmp := INIT_GRACE
|
||||
|
||||
# An actor interacting with this triggers a scene transtion
|
||||
func interact(n):
|
||||
transition(n)
|
||||
|
||||
func transition(n):
|
||||
if init_grace_tmp < 0:
|
||||
n.exit_point = exit_point
|
||||
|
@ -41,7 +46,10 @@ func exit_post_fixup(n):
|
|||
|
||||
func make_walk(n, walk_right, time):
|
||||
n.in_control = false
|
||||
n.input_dir.x = 1 if walk_right else -1
|
||||
if walk:
|
||||
n.input_dir.x = 1 if walk_right else -1
|
||||
else:
|
||||
n.input_dir.x = 0
|
||||
await get_tree().create_timer(time).timeout
|
||||
n.input_dir.x = 0
|
||||
n.in_control = true
|
||||
|
|
87
global/ui/InteractArrow.tscn
Normal file
87
global/ui/InteractArrow.tscn
Normal file
|
@ -0,0 +1,87 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://cm8apwrgu5r6s"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://d3u1x5ywauxvt" path="res://global/ui/interact-arrow.png" id="1_0ec3t"]
|
||||
[ext_resource type="Script" path="res://global/ui/interact_arrow.gd" id="2_3xtid"]
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_6njji"]
|
||||
particle_flag_disable_z = true
|
||||
emission_shape_scale = Vector3(10, 5, 1)
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 1.0
|
||||
gravity = Vector3(0, 98, 0)
|
||||
scale_max = 3.68
|
||||
|
||||
[sub_resource type="Animation" id="Animation_yq4vg"]
|
||||
resource_name = "default"
|
||||
length = 2.0
|
||||
loop_mode = 1
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:position:x")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(0, 0, 0),
|
||||
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, -3, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0, 1, 2)
|
||||
}
|
||||
tracks/1/type = "bezier"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:position:y")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"handle_modes": PackedInt32Array(0, 0, 0),
|
||||
"points": PackedFloat32Array(-86, -0.25, 0, 0.25, 0, -134, -0.25, 0, 0.25, 0, -86, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0, 1, 2)
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_pusks"]
|
||||
length = 0.001
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:position:x")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(0),
|
||||
"points": PackedFloat32Array(-3, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0)
|
||||
}
|
||||
tracks/1/type = "bezier"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:position:y")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"handle_modes": PackedInt32Array(0),
|
||||
"points": PackedFloat32Array(-134, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0)
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_anhqi"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_pusks"),
|
||||
"default": SubResource("Animation_yq4vg")
|
||||
}
|
||||
|
||||
[node name="InteractArrow" type="Sprite2D"]
|
||||
position = Vector2(-3, -134)
|
||||
scale = Vector2(3.197, 3)
|
||||
texture = ExtResource("1_0ec3t")
|
||||
script = ExtResource("2_3xtid")
|
||||
|
||||
[node name="GPUParticles2D" type="GPUParticles2D" parent="."]
|
||||
position = Vector2(-1.41593, -7.54717)
|
||||
process_material = SubResource("ParticleProcessMaterial_6njji")
|
||||
preprocess = 2.0
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_anhqi")
|
||||
}
|
||||
autoplay = "default"
|
BIN
global/ui/interact-arrow.png
(Stored with Git LFS)
Normal file
BIN
global/ui/interact-arrow.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
global/ui/interact-arrow.png.import
Normal file
34
global/ui/interact-arrow.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d3u1x5ywauxvt"
|
||||
path="res://.godot/imported/interact-arrow.png-e61086ed9dbb5f5d813ae4bcaa7e0319.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://global/ui/interact-arrow.png"
|
||||
dest_files=["res://.godot/imported/interact-arrow.png-e61086ed9dbb5f5d813ae4bcaa7e0319.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
11
global/ui/interact_arrow.gd
Normal file
11
global/ui/interact_arrow.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends Sprite2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
print("hello!", global_position)
|
|
@ -247,6 +247,12 @@ func _physics_process(delta):
|
|||
play_anim("jump")
|
||||
stm.transition(air, { "jump_stats" : current_state().dashjump_jump() })
|
||||
Debug.stat_set({ "key": "player dashjump", "indicate": true })
|
||||
# Interact
|
||||
if current_state() in [run] &&\
|
||||
get_interact_pressed() &&\
|
||||
get_dir().x == 0 &&\
|
||||
current_interactable != null:
|
||||
current_interactable.interact(self)
|
||||
# Hitboxes
|
||||
if current_state() in [run, air]:
|
||||
if hit_active:
|
||||
|
@ -307,6 +313,9 @@ func do_jump():
|
|||
func get_jump_pressed():
|
||||
return Input.is_action_just_pressed("jump")
|
||||
|
||||
func get_interact_pressed():
|
||||
return Input.is_action_just_pressed("interact")
|
||||
|
||||
func get_dir() -> Vector2:
|
||||
if !in_control:
|
||||
return input_dir
|
||||
|
@ -356,3 +365,17 @@ func _on_down_hit(_data):
|
|||
func _on_hurt_box_hurt(_data):
|
||||
lives -= 1
|
||||
Debug.stat_set({"key": "player health", "value": str(lives), "indicate": true})
|
||||
|
||||
var current_interactable = null
|
||||
var interact_arrow = preload("res://global/ui/InteractArrow.tscn")
|
||||
func _on_interact_box_area_entered(area):
|
||||
if current_interactable != null:
|
||||
current_interactable.get_node("InteractArrow").queue_free()
|
||||
current_interactable = area
|
||||
var arrow_instance = interact_arrow.instantiate()
|
||||
current_interactable.add_child(arrow_instance)
|
||||
|
||||
func _on_interact_box_area_exited(area):
|
||||
if current_interactable == area:
|
||||
current_interactable.get_node("InteractArrow").queue_free()
|
||||
current_interactable = null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=59 format=3 uid="uid://dlyt5o2dona1a"]
|
||||
[gd_scene load_steps=60 format=3 uid="uid://dlyt5o2dona1a"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/Player.gd" id="1_l3wc5"]
|
||||
[ext_resource type="Texture2D" uid="uid://mu78xlrkgmpq" path="res://assets/test_debug/updated player size v1.png" id="2_1bl0t"]
|
||||
|
@ -338,6 +338,9 @@ _data = {
|
|||
"dash": SubResource("Animation_4posc")
|
||||
}
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_gh4om"]
|
||||
size = Vector2(142, 245)
|
||||
|
||||
[node name="Player" type="CharacterBody2D" groups=["cross_scene", "debug_player_respawn", "debug_trail"]]
|
||||
collision_layer = 4
|
||||
script = ExtResource("1_l3wc5")
|
||||
|
@ -494,5 +497,16 @@ libraries = {
|
|||
"": SubResource("AnimationLibrary_6txnh")
|
||||
}
|
||||
|
||||
[node name="InteractBox" type="Area2D" parent="." groups=["flip_me"]]
|
||||
modulate = Color(1, 1, 0, 0.172549)
|
||||
collision_layer = 0
|
||||
collision_mask = 256
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="InteractBox"]
|
||||
position = Vector2(43, -3)
|
||||
shape = SubResource("RectangleShape2D_gh4om")
|
||||
|
||||
[connection signal="hurt" from="HurtBox" to="." method="_on_hurt_box_hurt"]
|
||||
[connection signal="hit" from="Hitboxes/Down" to="." method="_on_down_hit"]
|
||||
[connection signal="area_entered" from="InteractBox" to="." method="_on_interact_box_area_entered"]
|
||||
[connection signal="area_exited" from="InteractBox" to="." method="_on_interact_box_area_exited"]
|
||||
|
|
|
@ -177,6 +177,14 @@ debug_respawn_enemies={
|
|||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":78,"key_label":0,"unicode":110,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
interact={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
@ -187,6 +195,7 @@ debug_respawn_enemies={
|
|||
2d_physics/layer_2="Enemies"
|
||||
2d_physics/layer_3="Player"
|
||||
2d_physics/layer_4="EnmeyNono"
|
||||
2d_physics/layer_9="Interact"
|
||||
|
||||
[physics]
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ collision_layer = 0
|
|||
collision_mask = 4
|
||||
script = ExtResource("1_par51")
|
||||
scene = "res://test_levels/test_bad_performance2.tscn"
|
||||
enter_right = false
|
||||
exit_point = "PointColorado"
|
||||
enter_right = false
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="PointMaine"]
|
||||
shape = SubResource("RectangleShape2D_6n8gr")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=9 format=4 uid="uid://cwp72vpwvgfur"]
|
||||
[gd_scene load_steps=10 format=4 uid="uid://cwp72vpwvgfur"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dlyt5o2dona1a" path="res://player/Player.tscn" id="1_lafxi"]
|
||||
[ext_resource type="Script" path="res://global/SceneTransition.gd" id="2_b6h25"]
|
||||
|
@ -7,7 +7,10 @@
|
|||
[ext_resource type="Texture2D" uid="uid://3hyrbswjn4e" path="res://expressive_stone.png" id="7_2btar"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_6n8gr"]
|
||||
size = Vector2(53.5, 389)
|
||||
size = Vector2(82.594, 407)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_6wgqt"]
|
||||
size = Vector2(173.188, 141.375)
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v18bm"]
|
||||
texture = ExtResource("3_d5ovc")
|
||||
|
@ -35,8 +38,21 @@ scene = "res://test_levels/test_bad_performance.tscn"
|
|||
exit_point = "PointMaine"
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="PointColorado"]
|
||||
position = Vector2(16, -4.5)
|
||||
shape = SubResource("RectangleShape2D_6n8gr")
|
||||
|
||||
[node name="PointWyoming" type="Area2D" parent="."]
|
||||
position = Vector2(1450, 783)
|
||||
collision_layer = 256
|
||||
collision_mask = 0
|
||||
script = ExtResource("2_b6h25")
|
||||
scene = "res://test_levels/test_bad_performance.tscn"
|
||||
exit_point = "PointMaine"
|
||||
walk = false
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="PointWyoming"]
|
||||
shape = SubResource("RectangleShape2D_6wgqt")
|
||||
|
||||
[node name="TileMapLayer" type="TileMapLayer" parent="."]
|
||||
tile_map_data = PackedByteArray("AAABAAcAAgAAAAAAAAACAAcAAgAAAAAAAAADAAcAAgAAAAAAAAAEAAcAAgAAAAAAAAAFAAcAAgAAAAAAAAAGAAcAAgAAAAAAAAAHAAcAAgAAAAAAAAAIAAcAAgAAAAAAAAAJAAcAAgAAAAAAAAAKAAcAAgAAAAAAAAD///7/AgAAAAAAAAAAAP3/AgAAAAAAAAABAP3/AgAAAAAAAAABAAAAAgAAAAAAAAABAAEAAgAAAAAAAAAAAAEAAgAAAAAAAAAAAAAAAgAAAAAAAAD//wAAAgAAAAAAAAD+/wAAAgAAAAAAAAD+////AgAAAAAAAAD/////AgAAAAAAAAABAAMAAgAAAAAAAAABAAIAAgAAAAAAAAALAAcAAgAAAAAAAAAMAAcAAgAAAAAAAAANAAcAAgAAAAAAAAAOAAcAAgAAAAAAAAAPAAcAAgAAAAAAAAAQAAcAAgAAAAAAAAARAAcAAgAAAAAAAAASAAcAAgAAAAAAAAATAAcAAgAAAAAAAAAUAAcAAgAAAAAAAAAVAAcAAgAAAAAAAAAWAAcAAgAAAAAAAAAXAAcAAgAAAAAAAAAYAAcAAgAAAAAAAAAZAAcAAgAAAAAAAAAaAAcAAgAAAAAAAAAXAAMAAgAAAAAAAAAYAAMAAgAAAAAAAAAXAAIAAgAAAAAAAAAXAAEAAgAAAAAAAAAXAAAAAgAAAAAAAAAXAP//AgAAAAAAAAAXAP7/AgAAAAAAAAAWAP7/AgAAAAAAAAAWAP//AgAAAAAAAAAWAAAAAgAAAAAAAAAWAAEAAgAAAAAAAAAWAAIAAgAAAAAAAAAWAAMAAgAAAAAAAAAZAAMAAgAAAAAAAAA=")
|
||||
tile_set = SubResource("TileSet_v0hen")
|
||||
|
|
Loading…
Reference in a new issue