diff --git a/DebugMessageContainer.gd b/DebugMessageContainer.gd index 37edfcb..cca38d7 100644 --- a/DebugMessageContainer.gd +++ b/DebugMessageContainer.gd @@ -6,6 +6,7 @@ func _ready() -> void: GameEvents.add_message.connect(add_message) func add_message(message): + print(message) var new_label: Label = label_scene.instantiate() new_label.text = message add_child(new_label) diff --git a/OxygenComponent.gd b/OxygenComponent.gd index fd30ab1..88d2223 100644 --- a/OxygenComponent.gd +++ b/OxygenComponent.gd @@ -26,5 +26,5 @@ func _physics_process(delta: float) -> void: else: if count >= 0: count = clamp(count - replenish_rate * delta, 0, max_oxygen_seconds) - oxygen_bar.value = max_oxygen_seconds - count oxygen_bar.max_value = max_oxygen_seconds + oxygen_bar.value = max_oxygen_seconds - count diff --git a/main.tscn b/main.tscn index d29e388..29a001f 100644 --- a/main.tscn +++ b/main.tscn @@ -86,6 +86,7 @@ shape = SubResource("RectangleShape2D_wau00") debug_color = Color(0.666667, 0.933333, 1, 0.419608) [node name="UI" parent="." instance=ExtResource("3_0cdyn")] +visible = false [node name="Water" type="Polygon2D" parent="." node_paths=PackedStringArray("default_biome")] z_index = 1 diff --git a/player.aseprite b/player.aseprite index d6db4c9..a96bac3 100644 Binary files a/player.aseprite and b/player.aseprite differ diff --git a/player.gd b/player.gd index f19cda3..c7b28e0 100644 --- a/player.gd +++ b/player.gd @@ -38,7 +38,6 @@ func enter_water(): else: swim_target_angle = 0 swim_angle = 0 - animation_player.play("swim") float_component.set_in_water(true) motion_mode = CharacterBody2D.MOTION_MODE_FLOATING floor_constant_speed = false @@ -89,7 +88,10 @@ func _physics_process(delta): if velocity.y > max_fall_speed: velocity.y = max_fall_speed else: - animation_player.play("idle") + if direction_input: + animation_player.play("walk") + else: + animation_player.play("idle") if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = jump_vel @@ -129,7 +131,9 @@ func _physics_process(delta): velocity.y = move_toward(velocity.y, 0, water_friction_speed * delta) if direction_input: swim_target_angle = direction_input.angle() - swim_angle = rotate_toward(swim_angle, swim_target_angle, swim_rotation_speed * delta) + else: + swim_target_angle = 0 if sprite.scale.x == -1 else PI + swim_angle = lerp_angle(swim_angle, swim_target_angle, .1) GameEvents.add_debug_obj.emit("swim_angle", swim_angle) var currently_flipped = sprite.scale.x == -1 var dot_value = Vector2.RIGHT.dot(Vector2.from_angle(swim_angle)) @@ -137,6 +141,10 @@ func _physics_process(delta): GameEvents.add_debug_obj.emit("is_flipped", is_flipped) sprite.rotation = swim_angle if is_flipped else swim_angle + PI sprite.scale.x = -1 if is_flipped else 1 + if direction_input: + animation_player.play("swim") + else: + animation_player.play("swim_idle") diff --git a/player.json b/player.json index 158254c..a8be627 100644 --- a/player.json +++ b/player.json @@ -1,19 +1,107 @@ { "frames": { "player 0.aseprite": { - "frame": { "x": 30, "y": 2, "w": 20, "h": 21 }, + "frame": { "x": 41, "y": 46, "w": 17, "h": 21 }, "rotated": false, "trimmed": true, - "spriteSourceSize": { "x": 9, "y": 8, "w": 16, "h": 17 }, + "spriteSourceSize": { "x": 11, "y": 8, "w": 13, "h": 17 }, "sourceSize": { "w": 32, "h": 32 }, "duration": 100 }, "player 1.aseprite": { - "frame": { "x": 2, "y": 2, "w": 26, "h": 21 }, + "frame": { "x": 77, "y": 2, "w": 17, "h": 22 }, "rotated": false, "trimmed": true, - "spriteSourceSize": { "x": 8, "y": 8, "w": 22, "h": 17 }, + "spriteSourceSize": { "x": 10, "y": 8, "w": 13, "h": 18 }, "sourceSize": { "w": 32, "h": 32 }, - "duration": 100 + "duration": 200 + }, + "player 2.aseprite": { + "frame": { "x": 21, "y": 64, "w": 17, "h": 20 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 10, "y": 9, "w": 13, "h": 16 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 200 + }, + "player 3.aseprite": { + "frame": { "x": 50, "y": 22, "w": 17, "h": 22 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 10, "y": 8, "w": 13, "h": 18 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 200 + }, + "player 4.aseprite": { + "frame": { "x": 21, "y": 42, "w": 18, "h": 20 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 10, "y": 9, "w": 14, "h": 16 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 200 + }, + "player 5.aseprite": { + "frame": { "x": 2, "y": 47, "w": 17, "h": 21 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 11, "y": 8, "w": 13, "h": 17 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 400 + }, + "player 6.aseprite": { + "frame": { "x": 2, "y": 23, "w": 17, "h": 22 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 11, "y": 9, "w": 13, "h": 18 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 200 + }, + "player 7.aseprite": { + "frame": { "x": 60, "y": 50, "w": 17, "h": 21 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 11, "y": 8, "w": 13, "h": 17 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 400 + }, + "player 8.aseprite": { + "frame": { "x": 69, "y": 26, "w": 17, "h": 22 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 11, "y": 9, "w": 13, "h": 18 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 200 + }, + "player 9.aseprite": { + "frame": { "x": 26, "y": 22, "w": 22, "h": 18 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 9, "y": 8, "w": 18, "h": 14 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 250 + }, + "player 10.aseprite": { + "frame": { "x": 26, "y": 2, "w": 23, "h": 18 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 9, "y": 9, "w": 19, "h": 14 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 200 + }, + "player 11.aseprite": { + "frame": { "x": 2, "y": 2, "w": 22, "h": 19 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 9, "y": 8, "w": 18, "h": 15 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 250 + }, + "player 12.aseprite": { + "frame": { "x": 51, "y": 2, "w": 23, "h": 18 }, + "rotated": false, + "trimmed": true, + "spriteSourceSize": { "x": 9, "y": 9, "w": 19, "h": 14 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 200 } }, "meta": { @@ -21,11 +109,13 @@ "version": "1.3.6-x64", "image": "player.png", "format": "RGBA8888", - "size": { "w": 52, "h": 25 }, + "size": { "w": 96, "h": 86 }, "scale": "1", "frameTags": [ { "name": "idle", "from": 0, "to": 0, "direction": "forward", "color": "#000000ff" }, - { "name": "swim", "from": 1, "to": 1, "direction": "forward", "color": "#000000ff" } + { "name": "walk", "from": 1, "to": 4, "direction": "forward", "color": "#000000ff" }, + { "name": "swim_idle", "from": 5, "to": 8, "direction": "forward", "color": "#000000ff" }, + { "name": "swim", "from": 9, "to": 12, "direction": "forward", "color": "#000000ff" } ], "layers": [ { "name": "Layer 1", "opacity": 255, "blendMode": "normal" } diff --git a/player.png b/player.png index 78af45b..3fd7ed4 100644 Binary files a/player.png and b/player.png differ diff --git a/player.tscn b/player.tscn index 7830404..3b0f5b3 100644 --- a/player.tscn +++ b/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://mnaxd41w2loc"] +[gd_scene load_steps=14 format=3 uid="uid://mnaxd41w2loc"] [ext_resource type="Script" path="res://player.gd" id="1_b3cg5"] [ext_resource type="Texture2D" uid="uid://c4etptninfkid" path="res://player.png" id="2_7u1va"] @@ -29,7 +29,7 @@ tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 0, -"values": [Rect2(30, 2, 20, 21)] +"values": [Rect2(41, 46, 17, 21)] } tracks/1/type = "value" tracks/1/imported = false @@ -41,11 +41,11 @@ tracks/1/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 0, -"values": [Vector2(1, 0.5)] +"values": [Vector2(1.5, 0.5)] } [sub_resource type="Animation" id="Animation_vou52"] -length = 0.1 +length = 0.9 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -53,10 +53,10 @@ tracks/0/path = NodePath("Sprite:region_rect") tracks/0/interp = 0 tracks/0/loop_wrap = true tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), +"times": PackedFloat32Array(0, 0.25, 0.45, 0.7), +"transitions": PackedFloat32Array(1, 1, 1, 1), "update": 0, -"values": [Rect2(2, 2, 26, 21)] +"values": [Rect2(26, 22, 22, 18), Rect2(26, 2, 23, 18), Rect2(2, 2, 22, 19), Rect2(51, 2, 23, 18)] } tracks/1/type = "value" tracks/1/imported = false @@ -65,16 +65,73 @@ tracks/1/path = NodePath("Sprite:offset") tracks/1/interp = 0 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), +"times": PackedFloat32Array(0, 0.25, 0.45, 0.7), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(2, -1), Vector2(2.5, 0), Vector2(2, -0.5), Vector2(2.5, 0)] +} + +[sub_resource type="Animation" id="Animation_dnhxd"] +length = 0.8 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite:region_rect") +tracks/0/interp = 0 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.2, 0.4, 0.6), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Rect2(77, 2, 17, 22), Rect2(21, 64, 17, 20), Rect2(50, 22, 17, 22), Rect2(21, 42, 18, 20)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite:offset") +tracks/1/interp = 0 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.2, 0.4, 0.6), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(0.5, 1), Vector2(0.5, 1), Vector2(0.5, 1), Vector2(1, 1)] +} + +[sub_resource type="Animation" id="Animation_krkgp"] +length = 1.2 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite:region_rect") +tracks/0/interp = 0 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.4, 0.6, 1), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Rect2(2, 47, 17, 21), Rect2(2, 23, 17, 22), Rect2(60, 50, 17, 21), Rect2(69, 26, 17, 22)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite:offset") +tracks/1/interp = 0 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.4, 0.6, 1), +"transitions": PackedFloat32Array(1, 1, 1, 1), "update": 0, -"values": [Vector2(3, 0.5)] +"values": [Vector2(1.5, 0.5), Vector2(1.5, 2), Vector2(1.5, 0.5), Vector2(1.5, 2)] } [sub_resource type="AnimationLibrary" id="AnimationLibrary_781fc"] _data = { "idle": SubResource("Animation_woum7"), -"swim": SubResource("Animation_vou52") +"swim": SubResource("Animation_vou52"), +"swim_idle": SubResource("Animation_krkgp"), +"walk": SubResource("Animation_dnhxd") } [node name="Player" type="CharacterBody2D"] @@ -144,3 +201,4 @@ float_target = NodePath("../Sprite") libraries = { "": SubResource("AnimationLibrary_781fc") } +autoplay = "idle" diff --git a/ui.gd b/ui.gd new file mode 100644 index 0000000..33c7cc3 --- /dev/null +++ b/ui.gd @@ -0,0 +1,4 @@ +extends CanvasLayer + +func _ready(): + visible = true diff --git a/ui.tscn b/ui.tscn index 6850644..127cb42 100644 --- a/ui.tscn +++ b/ui.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=7 format=3 uid="uid://cjiok5o0qam3w"] +[gd_scene load_steps=8 format=3 uid="uid://cjiok5o0qam3w"] [ext_resource type="Script" path="res://DeathRect.gd" id="1_e1oy5"] [ext_resource type="Script" path="res://DebugLabel.gd" id="1_f57q1"] +[ext_resource type="Script" path="res://ui.gd" id="1_xy1r8"] [ext_resource type="Script" path="res://DebugMessageContainer.gd" id="2_n2sie"] [ext_resource type="PackedScene" uid="uid://b5jq1hyurpv6l" path="res://debug_messages.tscn" id="3_o0xii"] [ext_resource type="Script" path="res://VersionLabel.gd" id="4_5o7bk"] @@ -11,6 +12,8 @@ _data = [Vector2(0, 0), 0.0, 0.76295, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] point_count = 2 [node name="UI" type="CanvasLayer"] +visible = false +script = ExtResource("1_xy1r8") [node name="DeathRect" type="ColorRect" parent="."] anchors_preset = 15