diff --git a/game/levels/test_level.tscn b/game/levels/test_level.tscn index 299f981..b36371d 100644 --- a/game/levels/test_level.tscn +++ b/game/levels/test_level.tscn @@ -4,7 +4,7 @@ [ext_resource type="Script" uid="uid://bc114fx0hcb6s" path="res://game/levels/test_level.gd" id="2_a2sw7"] [ext_resource type="PackedScene" uid="uid://ct6n0u0iegynv" path="res://game/doors/lever_door.tscn" id="2_r01v2"] [ext_resource type="PackedScene" uid="uid://b3kyqvuxmfn8f" path="res://game/objects/decorative/fireplace.tscn" id="3_tuvkr"] -[ext_resource type="PackedScene" uid="uid://jab32eoyc523" path="res://game/platform/self_moving_platform.tscn" id="4_h1708"] +[ext_resource type="PackedScene" uid="uid://jab32eoyc523" path="res://game/platform/moving_platform.tscn" id="4_h1708"] [ext_resource type="PackedScene" uid="uid://g0n5npbt3hb2" path="res://game/doors/circle_door.tscn" id="4_yrqjd"] [ext_resource type="PackedScene" uid="uid://cojxqx5al7kyv" path="res://game/doors/locked_door.tscn" id="5_1skah"] [ext_resource type="PackedScene" uid="uid://dwvv5dj8lqif2" path="res://game/doors/triangle_door.tscn" id="6_75eok"] @@ -27,9 +27,9 @@ [sub_resource type="Curve2D" id="Curve2D_h1708"] _data = { -"points": PackedVector2Array(0, 0, 0, 0, 229, -75, 0, 0, 0, 0, 47, -75, 0, 0, 0, 0, 160, -26, 0, 0, 0, 0, 229, -75) +"points": PackedVector2Array(0, 0, 0, 0, 229, -75, 0, 0, 0, 0, 47, -75) } -point_count = 4 +point_count = 2 [node name="TestLevel" unique_id=600627332 instance=ExtResource("1_15okj")] script = ExtResource("2_a2sw7") @@ -38,10 +38,10 @@ script = ExtResource("2_a2sw7") position = Vector2(274, -81) platform_width = 48 -[node name="SelfMovingPlatform" parent="Platforms" parent_id_path=PackedInt32Array(1140671629) index="1" unique_id=349378100 node_paths=PackedStringArray("path_follow") instance=ExtResource("4_h1708")] +[node name="SelfMovingPlatform" parent="Platforms" parent_id_path=PackedInt32Array(1140671629) index="1" unique_id=349378100 node_paths=PackedStringArray("path", "path_follow") instance=ExtResource("4_h1708")] position = Vector2(201.03143, -75) rotation = -3.1415925 -is_loop = true +path = NodePath("../Path2D") path_follow = NodePath("../Path2D/PathFollow2D") platform_width = 104 diff --git a/game/platform/abstract_platform.gd b/game/platform/abstract_platform.gd index 4b7760e..b8f0824 100644 --- a/game/platform/abstract_platform.gd +++ b/game/platform/abstract_platform.gd @@ -3,6 +3,21 @@ class_name AbstractPlatform extends AnimatableBody2D +const ANIMATION_COLOR_SWITCHING = "color_switching" +const ANIMATION_HIDING = "hiding" +const ANIMATION_TIMER = "timer" + +const ANIMATION_SELF_MOVING = "self_moving" + +const ANIMATION_MOVING_PREFIX = "moving_" +const ANIMATION_MOVING_UP = "up" +const ANIMATION_MOVING_DOWN = "down" +const ANIMATION_MOVING_LEFT = "left" +const ANIMATION_MOVING_RIGHT = "right" +const ANIMATION_ACTIVE_SUFFIX = "_active" +const ANIMATION_STATIC_SUFFIX = "_static" + + const TILE_SIZE = 8 const MIN_WIDTH = TILE_SIZE * 2 const MAX_WIDTH = TILE_SIZE * 32 diff --git a/game/platform/abstract_platform.tscn b/game/platform/abstract_platform.tscn index ae667f6..2692751 100644 --- a/game/platform/abstract_platform.tscn +++ b/game/platform/abstract_platform.tscn @@ -4,6 +4,7 @@ [ext_resource type="Material" uid="uid://2hd2pw5cgn1r" path="res://game/materials/platform_gray.tres" id="2_2ivtb"] [ext_resource type="Texture2D" uid="uid://cpcuokqv8u2xa" path="res://images/level/platform.png" id="2_31xwx"] [ext_resource type="Shader" uid="uid://d4hm3vjx1rhsf" path="res://game/shaders/platform.gdshader" id="2_jsq8n"] +[ext_resource type="Texture2D" uid="uid://bi2h4g71bro7v" path="res://images/level/platform-icons.png" id="5_hgabr"] [sub_resource type="ViewportTexture" id="ViewportTexture_2ivtb"] viewport_path = NodePath("SubViewport") @@ -16,6 +17,478 @@ shader_parameter/platform_width = 24.0 shader_parameter/atlas = ExtResource("2_31xwx") shader_parameter/seed = 0.1415489 +[sub_resource type="AtlasTexture" id="AtlasTexture_hgabr"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_j4n83"] +atlas = ExtResource("5_hgabr") +region = Rect2(8, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_j4t02"] +atlas = ExtResource("5_hgabr") +region = Rect2(16, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_uwu3e"] +atlas = ExtResource("5_hgabr") +region = Rect2(24, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dtkpf"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 8, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_33abs"] +atlas = ExtResource("5_hgabr") +region = Rect2(8, 8, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_663ty"] +atlas = ExtResource("5_hgabr") +region = Rect2(16, 8, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_v0w7w"] +atlas = ExtResource("5_hgabr") +region = Rect2(24, 8, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rrd5t"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 56, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ml711"] +atlas = ExtResource("5_hgabr") +region = Rect2(8, 56, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7k0y4"] +atlas = ExtResource("5_hgabr") +region = Rect2(16, 56, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gdgnj"] +atlas = ExtResource("5_hgabr") +region = Rect2(24, 56, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_xw306"] +atlas = ExtResource("5_hgabr") +region = Rect2(32, 56, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dum6q"] +atlas = ExtResource("5_hgabr") +region = Rect2(40, 56, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yehga"] +atlas = ExtResource("5_hgabr") +region = Rect2(8, 24, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nqnxw"] +atlas = ExtResource("5_hgabr") +region = Rect2(16, 24, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ihg8w"] +atlas = ExtResource("5_hgabr") +region = Rect2(24, 24, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0y7uy"] +atlas = ExtResource("5_hgabr") +region = Rect2(32, 24, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5tx3c"] +atlas = ExtResource("5_hgabr") +region = Rect2(40, 24, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_uxm1i"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 24, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yj8cj"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 24, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ehe7o"] +atlas = ExtResource("5_hgabr") +region = Rect2(8, 32, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5v8yk"] +atlas = ExtResource("5_hgabr") +region = Rect2(16, 32, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ves0l"] +atlas = ExtResource("5_hgabr") +region = Rect2(24, 32, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nnitb"] +atlas = ExtResource("5_hgabr") +region = Rect2(32, 32, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dd62t"] +atlas = ExtResource("5_hgabr") +region = Rect2(40, 32, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_w5ro3"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 32, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5xqsc"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 32, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nkc6h"] +atlas = ExtResource("5_hgabr") +region = Rect2(8, 40, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ysy4a"] +atlas = ExtResource("5_hgabr") +region = Rect2(16, 40, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_lwy5x"] +atlas = ExtResource("5_hgabr") +region = Rect2(24, 40, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_km3nq"] +atlas = ExtResource("5_hgabr") +region = Rect2(32, 40, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mtmno"] +atlas = ExtResource("5_hgabr") +region = Rect2(40, 40, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qiapf"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 40, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_s6swh"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 40, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7ekpm"] +atlas = ExtResource("5_hgabr") +region = Rect2(8, 16, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_tki5g"] +atlas = ExtResource("5_hgabr") +region = Rect2(16, 16, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nkxw8"] +atlas = ExtResource("5_hgabr") +region = Rect2(24, 16, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0eeow"] +atlas = ExtResource("5_hgabr") +region = Rect2(32, 16, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_eokgk"] +atlas = ExtResource("5_hgabr") +region = Rect2(40, 16, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_n8r07"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 16, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vri0m"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 16, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dwv5n"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 48, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_w2vlx"] +atlas = ExtResource("5_hgabr") +region = Rect2(8, 48, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_eqsoo"] +atlas = ExtResource("5_hgabr") +region = Rect2(16, 48, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bc1yh"] +atlas = ExtResource("5_hgabr") +region = Rect2(24, 48, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7l6bg"] +atlas = ExtResource("5_hgabr") +region = Rect2(32, 48, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_17vh2"] +atlas = ExtResource("5_hgabr") +region = Rect2(40, 48, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4ep6y"] +atlas = ExtResource("5_hgabr") +region = Rect2(32, 48, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mwtcp"] +atlas = ExtResource("5_hgabr") +region = Rect2(24, 48, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_eb8av"] +atlas = ExtResource("5_hgabr") +region = Rect2(16, 48, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_egipa"] +atlas = ExtResource("5_hgabr") +region = Rect2(8, 48, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4g8bw"] +atlas = ExtResource("5_hgabr") +region = Rect2(0, 64, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mhe6c"] +atlas = ExtResource("5_hgabr") +region = Rect2(8, 64, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_d8o7t"] +atlas = ExtResource("5_hgabr") +region = Rect2(16, 64, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_txrl7"] +atlas = ExtResource("5_hgabr") +region = Rect2(24, 64, 8, 8) + +[sub_resource type="SpriteFrames" id="SpriteFrames_j4n83"] +animations = [{ +"frames": [{ +"duration": 5.0, +"texture": SubResource("AtlasTexture_hgabr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_j4n83") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_j4t02") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_uwu3e") +}, { +"duration": 5.0, +"texture": SubResource("AtlasTexture_dtkpf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_33abs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_663ty") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_v0w7w") +}], +"loop": true, +"name": &"color_switching", +"speed": 10.0 +}, { +"frames": [], +"loop": true, +"name": &"default", +"speed": 5.0 +}, { +"frames": [{ +"duration": 15.0, +"texture": SubResource("AtlasTexture_rrd5t") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ml711") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7k0y4") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gdgnj") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_xw306") +}, { +"duration": 2.0, +"texture": SubResource("AtlasTexture_dum6q") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_xw306") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gdgnj") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7k0y4") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ml711") +}], +"loop": true, +"name": &"hiding", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_yehga") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nqnxw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ihg8w") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0y7uy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5tx3c") +}, { +"duration": 3.0, +"texture": SubResource("AtlasTexture_uxm1i") +}], +"loop": true, +"name": &"moving_down_active", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_yj8cj") +}], +"loop": true, +"name": &"moving_down_static", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_ehe7o") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5v8yk") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ves0l") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nnitb") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dd62t") +}, { +"duration": 3.0, +"texture": SubResource("AtlasTexture_w5ro3") +}], +"loop": true, +"name": &"moving_left_active", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_5xqsc") +}], +"loop": true, +"name": &"moving_left_static", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_nkc6h") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ysy4a") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_lwy5x") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_km3nq") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mtmno") +}, { +"duration": 3.0, +"texture": SubResource("AtlasTexture_qiapf") +}], +"loop": true, +"name": &"moving_right_active", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_s6swh") +}], +"loop": true, +"name": &"moving_right_static", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_7ekpm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_tki5g") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nkxw8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0eeow") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_eokgk") +}, { +"duration": 3.0, +"texture": SubResource("AtlasTexture_n8r07") +}], +"loop": true, +"name": &"moving_up_active", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_vri0m") +}], +"loop": true, +"name": &"moving_up_static", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_dwv5n") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_w2vlx") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_eqsoo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bc1yh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7l6bg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_17vh2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4ep6y") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mwtcp") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_eb8av") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_egipa") +}], +"loop": true, +"name": &"self_moving", +"speed": 10.0 +}, { +"frames": [{ +"duration": 15.0, +"texture": SubResource("AtlasTexture_4g8bw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mhe6c") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_d8o7t") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_txrl7") +}], +"loop": true, +"name": &"timer", +"speed": 10.0 +}] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_jsq8n"] resource_local_to_scene = true size = Vector2(16, 7) @@ -53,6 +526,8 @@ size_flags_horizontal = 4 size_flags_vertical = 4 [node name="IconSprite" type="AnimatedSprite2D" parent="SubViewport" unique_id=1917841765] +position = Vector2(8, 4) +sprite_frames = SubResource("SpriteFrames_j4n83") [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=175449124] position = Vector2(0, -0.5) diff --git a/game/platform/moving_platform.gd b/game/platform/moving_platform.gd new file mode 100644 index 0000000..38d998b --- /dev/null +++ b/game/platform/moving_platform.gd @@ -0,0 +1,88 @@ +@tool +class_name MovingPlatform +extends AbstractPlatform + + +enum Type { + SelfMoving, + LeftRight, + RightLeft, + UpDown, + DownUp, +} + + +const ANIMATION_MAP : Dictionary[Type, Dictionary] = { + Type.LeftRight: { false: ANIMATION_MOVING_LEFT, true: ANIMATION_MOVING_RIGHT }, + Type.RightLeft: { false: ANIMATION_MOVING_RIGHT, true: ANIMATION_MOVING_LEFT }, + Type.UpDown: { false: ANIMATION_MOVING_UP, true: ANIMATION_MOVING_DOWN }, + Type.DownUp: { false: ANIMATION_MOVING_DOWN, true: ANIMATION_MOVING_UP }, +} + + +@export var is_loop := false +@export var type := Type.SelfMoving +@export var path : Path2D +@export var path_follow : PathFollow2D +@export_range(0, 25, 0.1) var speed : float = 10.0 + + +var is_moving := false +var is_reverse := false +var tween: Tween + + +@onready var restart_timer : Timer = $RestartTimer + + +func _ready() -> void: + super._ready() + if not Engine.is_editor_hint() and type == Type.SelfMoving: + start_movement() + else: + _select_animation() + + +func _select_animation() -> void: + if type == Type.SelfMoving: + if not icon_sprite.is_playing(): + icon_sprite.play(ANIMATION_SELF_MOVING) + return + + var direction : String = ANIMATION_MAP[type][is_reverse] + var suffix := ANIMATION_ACTIVE_SUFFIX if is_moving else ANIMATION_STATIC_SUFFIX + icon_sprite.play(ANIMATION_MOVING_PREFIX + direction + suffix) + + +func start_movement() -> void: + is_moving = true + if tween and tween.is_running(): + tween.kill() + _select_animation() + + var target_progress := 0.0 if is_reverse else path.curve.get_baked_length() + var distance := absf(target_progress - path_follow.progress) + var duration := distance / speed + + tween = create_tween() + var target_ratio := 0.0 if is_reverse else 1.0 + tween.tween_property(path_follow, "progress_ratio", target_ratio, duration) + tween.finished.connect(_restart_movement) + + +func stop_movement() -> void: + is_moving = false + if tween and tween.is_running(): + tween.kill() + _select_animation() + + +func _restart_movement() -> void: + is_moving = false + if is_loop: + path_follow.progress_ratio = 0 + else: + is_reverse = not is_reverse + + _select_animation() + restart_timer.start() diff --git a/game/platform/self_moving_platform.gd.uid b/game/platform/moving_platform.gd.uid similarity index 100% rename from game/platform/self_moving_platform.gd.uid rename to game/platform/moving_platform.gd.uid diff --git a/game/platform/moving_platform.tscn b/game/platform/moving_platform.tscn new file mode 100644 index 0000000..383cb90 --- /dev/null +++ b/game/platform/moving_platform.tscn @@ -0,0 +1,46 @@ +[gd_scene format=3 uid="uid://jab32eoyc523"] + +[ext_resource type="PackedScene" uid="uid://guvijso3k6eq" path="res://game/platform/abstract_platform.tscn" id="1_aar0q"] +[ext_resource type="Script" uid="uid://cwji3vqis6w6b" path="res://game/platform/moving_platform.gd" id="2_c250g"] +[ext_resource type="Shader" uid="uid://d4hm3vjx1rhsf" path="res://game/shaders/platform.gdshader" id="3_7t213"] +[ext_resource type="Texture2D" uid="uid://cpcuokqv8u2xa" path="res://images/level/platform.png" id="4_8q4q1"] + +[sub_resource type="ViewportTexture" id="ViewportTexture_aar0q"] +viewport_path = NodePath("SubViewport") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_c250g"] +resource_local_to_scene = true +shader = ExtResource("3_7t213") +shader_parameter/tile_size = 8.0 +shader_parameter/platform_width = 24.0 +shader_parameter/atlas = ExtResource("4_8q4q1") +shader_parameter/seed = 0.94376683 + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_7t213"] +resource_local_to_scene = true +size = Vector2(16, 7) + +[node name="MovingPlatform" unique_id=137546339 instance=ExtResource("1_aar0q")] +script = ExtResource("2_c250g") +is_loop = false +type = 0 +speed = 10.0 + +[node name="Sprite2D" parent="." index="0" unique_id=264863796] +texture = SubResource("ViewportTexture_aar0q") + +[node name="PlatformRect" parent="SubViewport" parent_id_path=PackedInt32Array(226200089) index="0" unique_id=794315918] +material = SubResource("ShaderMaterial_c250g") + +[node name="IconSprite" parent="SubViewport" parent_id_path=PackedInt32Array(226200089) index="1" unique_id=1917841765] +animation = &"self_moving" +frame_progress = 0.80246073 + +[node name="CollisionShape2D" parent="." index="2" unique_id=175449124] +shape = SubResource("RectangleShape2D_7t213") + +[node name="RestartTimer" type="Timer" parent="." index="3" unique_id=1793755125] +wait_time = 3.0 +one_shot = true + +[connection signal="timeout" from="RestartTimer" to="." method="start_movement"] diff --git a/game/platform/platform_path.tscn b/game/platform/platform_path.tscn deleted file mode 100644 index 9a044e0..0000000 --- a/game/platform/platform_path.tscn +++ /dev/null @@ -1,3 +0,0 @@ -[gd_scene format=3 uid="uid://egknefyib2ui"] - -[node name="PlatformPath" type="Line2D" unique_id=2089103569] diff --git a/game/platform/self_moving_platform.gd b/game/platform/self_moving_platform.gd deleted file mode 100644 index e1d056b..0000000 --- a/game/platform/self_moving_platform.gd +++ /dev/null @@ -1,50 +0,0 @@ -@tool -class_name SelfMovingPlatform -extends AbstractPlatform - - -const SPEED_FACTOR = 0.025 -const ANIMATION_ACTIVE = "active" - - -@export var is_loop := false -@export var path_follow : PathFollow2D -@export_range(0, 25, 0.1) var speed : float = 10.0 - - -var is_reverse := false -var tween: Tween - - -func _ready() -> void: - super._ready() - icon_sprite.play(ANIMATION_ACTIVE) - if not Engine.is_editor_hint(): - _start_movement() - - -func _start_movement() -> void: - if tween and tween.is_running(): - tween.kill() - - var target := 0.0 if is_reverse else 1.0 - var distance := absf(target - path_follow.progress_ratio) - var duration := distance / (speed * SPEED_FACTOR) - - tween = create_tween() - - if not is_loop: - tween.set_trans(Tween.TRANS_SINE) - tween.set_ease(Tween.EASE_IN_OUT) - tween.finished.connect(_on_tween_finished) - - tween.tween_property(path_follow, "progress_ratio", target, duration) - - -func _on_tween_finished() -> void: - if is_loop: - path_follow.progress_ratio = 0 - else: - is_reverse = not is_reverse - - _start_movement() diff --git a/game/platform/self_moving_platform.tscn b/game/platform/self_moving_platform.tscn deleted file mode 100644 index 39f2b27..0000000 --- a/game/platform/self_moving_platform.tscn +++ /dev/null @@ -1,119 +0,0 @@ -[gd_scene format=3 uid="uid://jab32eoyc523"] - -[ext_resource type="PackedScene" uid="uid://guvijso3k6eq" path="res://game/platform/abstract_platform.tscn" id="1_jmy7p"] -[ext_resource type="Script" uid="uid://cwji3vqis6w6b" path="res://game/platform/self_moving_platform.gd" id="2_ayqtn"] -[ext_resource type="Shader" uid="uid://d4hm3vjx1rhsf" path="res://game/shaders/platform.gdshader" id="2_ex4q8"] -[ext_resource type="Texture2D" uid="uid://cpcuokqv8u2xa" path="res://images/level/platform.png" id="3_ayqtn"] -[ext_resource type="Texture2D" uid="uid://bi2h4g71bro7v" path="res://images/level/platform-icons.png" id="5_ayqtn"] - -[sub_resource type="ViewportTexture" id="ViewportTexture_ayqtn"] -viewport_path = NodePath("SubViewport") - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_v7ftt"] -resource_local_to_scene = true -shader = ExtResource("2_ex4q8") -shader_parameter/tile_size = 8.0 -shader_parameter/platform_width = 24.0 -shader_parameter/atlas = ExtResource("3_ayqtn") -shader_parameter/seed = 0.94376683 - -[sub_resource type="AtlasTexture" id="AtlasTexture_v7ftt"] -atlas = ExtResource("5_ayqtn") -region = Rect2(0, 48, 8, 8) - -[sub_resource type="AtlasTexture" id="AtlasTexture_xuyth"] -atlas = ExtResource("5_ayqtn") -region = Rect2(8, 48, 8, 8) - -[sub_resource type="AtlasTexture" id="AtlasTexture_4wvh7"] -atlas = ExtResource("5_ayqtn") -region = Rect2(16, 48, 8, 8) - -[sub_resource type="AtlasTexture" id="AtlasTexture_q6fss"] -atlas = ExtResource("5_ayqtn") -region = Rect2(24, 48, 8, 8) - -[sub_resource type="AtlasTexture" id="AtlasTexture_myyrw"] -atlas = ExtResource("5_ayqtn") -region = Rect2(32, 48, 8, 8) - -[sub_resource type="AtlasTexture" id="AtlasTexture_q3dcw"] -atlas = ExtResource("5_ayqtn") -region = Rect2(40, 48, 8, 8) - -[sub_resource type="AtlasTexture" id="AtlasTexture_gb0pd"] -atlas = ExtResource("5_ayqtn") -region = Rect2(32, 48, 8, 8) - -[sub_resource type="AtlasTexture" id="AtlasTexture_sqmiv"] -atlas = ExtResource("5_ayqtn") -region = Rect2(24, 48, 8, 8) - -[sub_resource type="AtlasTexture" id="AtlasTexture_mvt4t"] -atlas = ExtResource("5_ayqtn") -region = Rect2(16, 48, 8, 8) - -[sub_resource type="AtlasTexture" id="AtlasTexture_ppe0t"] -atlas = ExtResource("5_ayqtn") -region = Rect2(8, 48, 8, 8) - -[sub_resource type="SpriteFrames" id="SpriteFrames_22kvf"] -animations = [{ -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_v7ftt") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_xuyth") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_4wvh7") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_q6fss") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_myyrw") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_q3dcw") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_gb0pd") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_sqmiv") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_mvt4t") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_ppe0t") -}], -"loop": true, -"name": &"active", -"speed": 10.0 -}] - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_xuyth"] -resource_local_to_scene = true -size = Vector2(16, 7) - -[node name="SelfMovingPlatform" unique_id=137546339 instance=ExtResource("1_jmy7p")] -script = ExtResource("2_ayqtn") -speed = 10.0 - -[node name="Sprite2D" parent="." index="0" unique_id=264863796] -texture = SubResource("ViewportTexture_ayqtn") - -[node name="PlatformRect" parent="SubViewport" parent_id_path=PackedInt32Array(226200089) index="0" unique_id=794315918] -material = SubResource("ShaderMaterial_v7ftt") - -[node name="IconSprite" parent="SubViewport" parent_id_path=PackedInt32Array(226200089) index="1" unique_id=1917841765] -position = Vector2(8, 4) -sprite_frames = SubResource("SpriteFrames_22kvf") -animation = &"active" -frame_progress = 0.974508 - -[node name="CollisionShape2D" parent="." index="2" unique_id=175449124] -shape = SubResource("RectangleShape2D_xuyth") diff --git a/images/level/platform-icons.png b/images/level/platform-icons.png index 196973a..b0d0467 100644 --- a/images/level/platform-icons.png +++ b/images/level/platform-icons.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5013f3a4ec99f6ce686eb2b2324b0394fce66353f6b219cbbe0016f9de4bd630 -size 323 +oid sha256:2bc29eb0ded15408aabfd7d3235118daad730331b2e0d5ebba54ec1c52f4d487 +size 364