Level transition improvments.

This commit is contained in:
Dustin 2025-03-30 11:15:07 -07:00
parent bd991d7939
commit 7e9227064b
12 changed files with 31 additions and 11 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -4,7 +4,8 @@ extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var player_start_position: Position2D
##TODO: Should be based on screen position for starter
onready var player_start_position := Vector2(50,50)
func change_level(_level_name :String):
print("res://src/levels/" + _level_name + ".tscn" )
@ -21,6 +22,7 @@ func change_level(_level_name :String):
get_node("/root/Main").remove_child(l)
get_node("/root/Main").add_child(new_level)
get_node("/root/Main").move_child(new_level,1)
##TODO: Probably set start position
print (get_node("/root/Main").get_children())
SceneTransition.reset()
#get_node("/root/Main").add_child_below_node(SceneTransition,new_level)

View File

@ -5,6 +5,7 @@ extends Interactable
## helps the Player object pick an appropriate animation
export var _transition_type := 'door_right'
export var _destination_position_name := 'PlayerStart'
# Declare member variables here. Examples:
# var a = 2
# var b = "text"

View File

@ -169,8 +169,10 @@ func _state_process_physics_enter_right():
#flip_sprite_to_movement_direction()
if current_state.state_timeout.time_left == 0 and level_transition_latch == false:
#desired_movement_vector.x = LEFT
parent.transform.x.x = LEFT
##TODO: Optionally flip direction
#parent.transform.x.x = LEFT
## Reset global position.
parent.global_position = LevelInfo.player_start_position
current_state.state_timeout.start()
level_transition_latch = true
elif current_state.state_timeout.time_left == 0 and level_transition_latch == true:

View File

@ -1,5 +1,6 @@
extends Actor
export var player_number: int = 1
# Declare member variables here. Examples:
# var a = 2
@ -9,6 +10,8 @@ extends Actor
# Called when the node enters the scene tree for the first time.
func _ready():
PlayerInfo.player_health = $Health_Component.health
# Set initial player position in world.
global_position = LevelInfo.player_start_position
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -32,7 +35,8 @@ func touch_the_thing(the_thing: Interactable) -> bool:
the_thing.trigger_interaction()
return false
if the_thing is LevelTransition:
if the_thing._transition_type == 'door_right':
movement_state_machine.change_to_known_state('enter_right')
the_thing.trigger_interaction()
if movement_state_machine.current_state.name != 'enter_right':
if the_thing._transition_type == 'door_right':
movement_state_machine.change_to_known_state('enter_right')
the_thing.trigger_interaction()
return true

View File

@ -46,6 +46,7 @@ extents = Vector2( 9, 15 )
[node name="PlayerE" instance=ExtResource( 1 )]
script = ExtResource( 3 )
actor_type = "Player"
player_number = 1
[node name="Movement_StateMachine" parent="." index="0"]
starting_state_name = "idle"

View File

@ -6,7 +6,7 @@
resource_local_to_scene = true
script = ExtResource( 1 )
debug_state = false
timeout_seconds = 1.5
timeout_seconds = 1.0
name = "enter_right"
horizontal_speed = 30.0
horizontal_acceleration = 0.0

View File

@ -7,12 +7,15 @@ extends Node2D
# var b = "text"
onready var player_start = $PlayerStart
var entrances:Dictionary
# Called when the node enters the scene tree for the first time.
func _ready():
LevelInfo.player_start_position = player_start
LevelInfo.player_start_position = player_start.transform.origin
for ent in get_children():
if ent is Position2D:
entrances[ent.name] = ent
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):

View File

@ -11,7 +11,7 @@ radius = 5.09902
[node name="TileMap Collision" parent="." index="1"]
tile_set = ExtResource( 2 )
tile_data = PoolIntArray( 0, 4, 65536, 19, 4, 65536, 65536, 4, 65536, 65555, 4, 65536, 131072, 4, 65536, 131091, 4, 65536, 196608, 4, 65536, 196620, 2, 0, 196621, 2, 1, 196622, 2, 2, 196627, 4, 65536, 262144, 4, 0, 262156, 2, 65536, 262157, 2, 65537, 262158, 2, 65538, 262163, 4, 0, 327680, 4, 65536, 327699, 4, 65536, 393216, 4, 65536, 458752, 4, 65536, 589823, 0, 1, 524288, 4, 131072, 524289, 0, 3, 524290, 0, 1, 524291, 0, 2, 524292, 0, 3, 524293, 0, 1, 524294, 0, 2, 524295, 0, 3, 524296, 0, 1, 524297, 0, 2, 524298, 0, 3, 524299, 0, 1, 524300, 0, 2, 524301, 0, 3, 524302, 0, 1, 524303, 0, 2, 524304, 0, 3, 524305, 0, 1, 524306, 0, 2, 524308, 0, 1, 524309, 0, 2, 524310, 0, 3, 655359, 0, 65537, 589824, 0, 65538, 589825, 0, 65539, 589826, 0, 65537, 589827, 0, 65538, 589828, 0, 65539, 589829, 0, 65537, 589830, 0, 65538, 589831, 0, 65539, 589832, 0, 65537, 589833, 0, 65538, 589834, 0, 65539, 589835, 0, 65537, 589836, 0, 65538, 589837, 0, 65539, 589838, 0, 65537, 589839, 0, 65538, 589840, 0, 65539, 589841, 0, 65537, 589842, 0, 65538, 589843, 0, 65539, 589844, 0, 65537, 589845, 0, 65538, 589846, 0, 65539, 720895, 0, 131073, 655360, 0, 131074, 655361, 0, 131075, 655362, 0, 131073, 655363, 0, 131074, 655364, 0, 131075, 655365, 0, 131073, 655366, 0, 131074, 655367, 0, 131075, 655368, 0, 131073, 655369, 0, 131074, 655370, 0, 131075, 655371, 0, 131073, 655372, 0, 131074, 655373, 0, 131075, 655374, 0, 131073, 655375, 0, 131074, 655376, 0, 131075, 655377, 0, 131073, 655378, 0, 131074, 655379, 0, 131075, 655380, 0, 131073, 655381, 0, 131074, 655382, 0, 131075, 786431, 0, 196609, 720896, 0, 196610, 720897, 0, 196611, 720898, 0, 196609, 720899, 0, 196610, 720900, 0, 196611, 720901, 0, 196609, 720902, 0, 196610, 720903, 0, 196611, 720904, 0, 196609, 720905, 0, 196610, 720906, 0, 196611, 720907, 0, 196609, 720908, 0, 196610, 720909, 0, 196611, 720910, 0, 196609, 720911, 0, 196610, 720912, 0, 196611, 720913, 0, 196609, 720914, 0, 196610, 720915, 0, 196611, 720916, 0, 196609, 720917, 0, 196610, 720918, 0, 196611, 851967, 0, 262145, 786432, 0, 262146, 786433, 0, 262147, 786434, 0, 262145, 786435, 0, 262146, 786436, 0, 262147, 786437, 0, 262145, 786438, 0, 262146, 786439, 0, 262147, 786440, 0, 262145, 786441, 0, 262146, 786442, 0, 262147, 786443, 0, 262145, 786444, 0, 262146, 786445, 0, 262147, 786446, 0, 262145, 786447, 0, 262146, 786448, 0, 262147, 786449, 0, 262145, 786450, 0, 262146, 786451, 0, 262147, 786452, 0, 262145, 786453, 0, 262146, 786454, 0, 262147 )
tile_data = PoolIntArray( -196609, 4, 0, -131073, 4, 0, -65537, 4, 0, -3, 4, 0, -2, 4, 0, -1, 4, 0, -65517, 4, 0, 65533, 4, 0, 19, 4, 65536, 131069, 4, 0, 65555, 4, 65536, 196605, 4, 0, 131073, 2, 1, 131074, 2, 2, 131091, 4, 65536, 262141, 4, 0, 262142, 4, 0, 262143, 4, 0, 196608, 4, 65536, 196609, 2, 65537, 196610, 2, 65538, 196627, 4, 65536, 262144, 4, 0, 262163, 4, 0, 327680, 4, 65536, 327699, 4, 65536, 393216, 4, 65536, 393235, 4, 65536, 458752, 4, 65536, 458771, 4, 65536, 589823, 0, 1, 524288, 4, 131072, 524289, 0, 3, 524290, 0, 1, 524291, 0, 2, 524292, 0, 3, 524293, 0, 1, 524294, 0, 2, 524295, 0, 3, 524296, 0, 1, 524297, 0, 2, 524298, 0, 3, 524299, 0, 1, 524300, 0, 2, 524301, 0, 3, 524302, 0, 1, 524303, 0, 2, 524304, 0, 3, 524305, 0, 1, 524306, 0, 2, 524307, 4, 0, 524308, 0, 1, 524309, 0, 2, 524310, 0, 3, 655359, 0, 65537, 589824, 0, 65538, 589825, 0, 65539, 589826, 0, 65537, 589827, 0, 65538, 589828, 0, 65539, 589829, 0, 65537, 589830, 0, 65538, 589831, 0, 65539, 589832, 0, 65537, 589833, 0, 65538, 589834, 0, 65539, 589835, 0, 65537, 589836, 0, 65538, 589837, 0, 65539, 589838, 0, 65537, 589839, 0, 65538, 589840, 0, 65539, 589841, 0, 65537, 589842, 0, 65538, 589843, 0, 65539, 589844, 0, 65537, 589845, 0, 65538, 589846, 0, 65539, 720895, 0, 131073, 655360, 0, 131074, 655361, 0, 131075, 655362, 0, 131073, 655363, 0, 131074, 655364, 0, 131075, 655365, 0, 131073, 655366, 0, 131074, 655367, 0, 131075, 655368, 0, 131073, 655369, 0, 131074, 655370, 0, 131075, 655371, 0, 131073, 655372, 0, 131074, 655373, 0, 131075, 655374, 0, 131073, 655375, 0, 131074, 655376, 0, 131075, 655377, 0, 131073, 655378, 0, 131074, 655379, 0, 131075, 655380, 0, 131073, 655381, 0, 131074, 655382, 0, 131075, 786431, 0, 196609, 720896, 0, 196610, 720897, 0, 196611, 720898, 0, 196609, 720899, 0, 196610, 720900, 0, 196611, 720901, 0, 196609, 720902, 0, 196610, 720903, 0, 196611, 720904, 0, 196609, 720905, 0, 196610, 720906, 0, 196611, 720907, 0, 196609, 720908, 0, 196610, 720909, 0, 196611, 720910, 0, 196609, 720911, 0, 196610, 720912, 0, 196611, 720913, 0, 196609, 720914, 0, 196610, 720915, 0, 196611, 720916, 0, 196609, 720917, 0, 196610, 720918, 0, 196611, 851967, 0, 262145, 786432, 0, 262146, 786433, 0, 262147, 786434, 0, 262145, 786435, 0, 262146, 786436, 0, 262147, 786437, 0, 262145, 786438, 0, 262146, 786439, 0, 262147, 786440, 0, 262145, 786441, 0, 262146, 786442, 0, 262147, 786443, 0, 262145, 786444, 0, 262146, 786445, 0, 262147, 786446, 0, 262145, 786447, 0, 262146, 786448, 0, 262147, 786449, 0, 262145, 786450, 0, 262146, 786451, 0, 262147, 786452, 0, 262145, 786453, 0, 262146, 786454, 0, 262147 )
[node name="TileMap Foreground" parent="." index="2"]
tile_set = ExtResource( 2 )
@ -19,6 +19,9 @@ collision_layer = 0
collision_mask = 0
tile_data = PoolIntArray( 524288, 0, 2, 524307, 0, 3 )
[node name="PlayerStart" parent="." index="3"]
position = Vector2( -7, 28 )
[node name="Hitbox_Component" parent="." index="4" instance=ExtResource( 3 )]
damage_amount = 10

View File

@ -23,6 +23,9 @@ collision_layer = 0
collision_mask = 0
tile_data = PoolIntArray( 524288, 0, 2, 524307, 0, 3 )
[node name="PlayerStart" parent="." index="3"]
position = Vector2( 80, 131 )
[node name="Hitbox_Component" parent="." index="4" instance=ExtResource( 3 )]
damage_amount = 10

View File

@ -12,6 +12,7 @@ var animation_name = ''
func reset():
$AnimationPlayer.play_backwards(animation_name)
emit_signal("done")
func transition_dissolve(target: String) -> void:
animation_name = 'dissolve'

View File

@ -96,5 +96,5 @@ anims/dissolve = SubResource( 4 )
[node name="clouds" type="TextureRect" parent="."]
margin_top = 180.0
margin_right = 320.0
margin_bottom = 360.0
margin_bottom = 400.0
texture = ExtResource( 2 )