diff --git a/assets/elevator.png b/assets/elevator.png new file mode 100644 index 0000000..e175bb8 Binary files /dev/null and b/assets/elevator.png differ diff --git a/assets/elevator.png.import b/assets/elevator.png.import new file mode 100644 index 0000000..1be748e --- /dev/null +++ b/assets/elevator.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/elevator.png-acbb9d6b280a7beb809eaa023b52f90b.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/elevator.png" +dest_files=[ "res://.import/elevator.png-acbb9d6b280a7beb809eaa023b52f90b.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/src/Actors/Platform/PlatformVMove/PlatformVMove.tscn b/src/Actors/Platform/PlatformVMove/PlatformVMove.tscn index d6f6452..a4bfad5 100644 --- a/src/Actors/Platform/PlatformVMove/PlatformVMove.tscn +++ b/src/Actors/Platform/PlatformVMove/PlatformVMove.tscn @@ -1,25 +1,82 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=13 format=2] [ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1] [ext_resource path="res://src/Actors/Platform/PlatformVMove/states2/move.gd" type="Script" id=2] [ext_resource path="res://src/Actors/Platform/PlatformVMove/states2/idle.gd" type="Script" id=3] +[sub_resource type="StreamTexture" id=1] +load_path = "res://.import/elevator.png-acbb9d6b280a7beb809eaa023b52f90b.stex" + +[sub_resource type="AtlasTexture" id=2] +atlas = SubResource( 1 ) +region = Rect2( 0, 0, 86, 44 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = SubResource( 1 ) +region = Rect2( 86, 0, 86, 44 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = SubResource( 1 ) +region = Rect2( 172, 0, 86, 44 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = SubResource( 1 ) +region = Rect2( 0, 44, 86, 44 ) + +[sub_resource type="AtlasTexture" id=6] +atlas = SubResource( 1 ) +region = Rect2( 86, 44, 86, 44 ) + +[sub_resource type="AtlasTexture" id=7] +atlas = SubResource( 1 ) +region = Rect2( 172, 44, 86, 44 ) + +[sub_resource type="SpriteFrames" id=8] +animations = [ { +"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ) ], +"loop": true, +"name": "default", +"speed": 5.0 +} ] + +[sub_resource type="RectangleShape2D" id=9] +extents = Vector2( 38, 15.5 ) + [node name="PlatformVMove" instance=ExtResource( 1 )] +collision_layer = 1 +collision_mask = 0 [node name="AnimatedSprite" parent="." index="0"] -frame = 0 +frames = SubResource( 8 ) +frame = 5 +__meta__ = { +"_aseprite_wizard_config_": { +"layer": "", +"o_ex_p": "", +"o_folder": "res://assets", +"o_name": "", +"only_visible": true, +"op_exp": false, +"slice": "", +"source": "D:/Sync/Assets/Library/elevator.ase" +} +} -[node name="CollisionShape2D" parent="." index="1"] -position = Vector2( 0, 1 ) +[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"] +position = Vector2( 0, -3.5 ) +shape = SubResource( 9 ) + +[node name="movement_state_machine" parent="." index="3"] +debug_state_machine = true [node name="idle" parent="movement_state_machine" index="0"] script = ExtResource( 3 ) -animation_sequence = [ ] -fall_node = NodePath("") -move_node = NodePath("") +debug_state = true +timeout_seconds = 2.0 +move_speed = 0.0 [node name="move" parent="movement_state_machine" index="2"] script = ExtResource( 2 ) -animation_sequence = [ ] -fall_node = NodePath("") -idle_node = NodePath("") +debug_state = true +timeout_seconds = 1.0 +move_speed = 30.0 diff --git a/src/Actors/Platform/PlatformVMove/states2/idle.gd b/src/Actors/Platform/PlatformVMove/states2/idle.gd index 250c59c..fc87bd6 100644 --- a/src/Actors/Platform/PlatformVMove/states2/idle.gd +++ b/src/Actors/Platform/PlatformVMove/states2/idle.gd @@ -1,17 +1,20 @@ extends StateAnimatedActor -export (NodePath) var fall_node export (NodePath) var move_node -onready var fall_state: State = get_node(fall_node) onready var move_state: State = get_node(move_node) func enter() -> void: .enter() # parent.set_hurtbox(true) - move_component.velocity.x = 0 if debug_state: print(owner.name, " Move Component: ", move_component.desired_movement_vector.x) + state_timeout.start() + +func process_frame(delta): + if state_timeout.time_left == 0: + return move_state + return null func process_physics(delta: float) -> State: @@ -20,11 +23,4 @@ func process_physics(delta: float) -> State: # parent.velocity.x = move_component.desired_movement_vector.x * move_speed # parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1)) - move_actor_as_desired(delta) - - if move_component.velocity.x != 0.0: - return move_state - - if !parent.is_on_floor(): - return fall_state return null diff --git a/src/Actors/Platform/PlatformVMove/states2/move.gd b/src/Actors/Platform/PlatformVMove/states2/move.gd index f93dab5..4113da8 100644 --- a/src/Actors/Platform/PlatformVMove/states2/move.gd +++ b/src/Actors/Platform/PlatformVMove/states2/move.gd @@ -1,21 +1,31 @@ extends StateAnimatedActor -export (NodePath) var fall_node export (NodePath) var idle_node -onready var fall_state: State = get_node(fall_node) onready var idle_state: State = get_node(idle_node) +var flip_flop:bool = true + +func enter() -> void: + .enter() +# parent.set_hurtbox(true) + if debug_state: + print(owner.name, " Move Component: ", move_component.desired_movement_vector.x) + state_timeout.start() + + func process_physics(delta: float) -> State: - move_actor_as_desired(delta) - - if move_component.velocity.x == 0.0: - return idle_state - - #Flip the character before tha actual move maybe. - parent.transform.x.x = move_component.get_movement_direction() + if state_timeout.time_left == 0: + if flip_flop: + move_component.velocity.y = move_speed + flip_flop = false + return idle_state + else: + move_component.velocity.y = move_speed * - 1 + flip_flop = true + return idle_state + + move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1)) - if !parent.is_on_floor(): - return fall_state return null diff --git a/src/Levels/Level.tscn b/src/Levels/Level.tscn index f5a1a46..4c58b92 100644 --- a/src/Levels/Level.tscn +++ b/src/Levels/Level.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=17 format=2] +[gd_scene load_steps=18 format=2] +[ext_resource path="res://src/Actors/Platform/PlatformVMove/PlatformVMove.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/Tiles/Assets/Demo TileSet.tres" type="TileSet" id=2] [ext_resource path="res://assets/Backgrounds/bgmuck.png" type="Texture" id=3] [ext_resource path="res://src/Interactables/Chest.tscn" type="PackedScene" id=4] @@ -174,3 +175,6 @@ collision_mask = 0 modulate = Color( 0.360784, 0.0901961, 0.0901961, 1 ) position = Vector2( 441, 283 ) shape = SubResource( 6 ) + +[node name="PlatformVMove" parent="." instance=ExtResource( 1 )] +position = Vector2( 359, 319 )