Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions scenes/quests/story_quests/champ/4_outro/champ_animation.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: The Threadbare Authors
# SPDX-License-Identifier: MPL-2.0
extends CharacterBody2D

@onready var champ_animation: AnimatedSprite2D = $AnimatedSprite2D

var swim_speed: int = 100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var swim_speed: int = 100
@export var swim_speed: int = 100

Perhaps?


func _ready() -> void:
# Give champ a starting swim speed
velocity.x = swim_speed

func _physics_process(_delta: float) -> void:
# Make sure Champ doesn't swim out of the water!
# If he gets too close, turn him around and start swimming the other direction
if position.x > 400 or position.x < 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is a CharacterBody2D, you could also do this by having invisible walls that it collides with, and handling move_and_slide() returning true (i.e. a collision occurred) by flipping the velocity.

(Not saying you have to change this, just an idea.)

champ_animation.scale.x *= -1
velocity.x *= -1
Comment on lines +17 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way you might spell this is:

Suggested change
champ_animation.scale.x *= -1
velocity.x *= -1
velocity.x *= -1
champ_animation.flip_h = velocity.x < 0

I think the difference is that flip_h only applies to the texture itself, whereas setting scale.x = -1 would also flip any child nodes. In this particular case they are equivalent. Just leaving a note about what we do elsewhere in the project, e.g

if not is_zero_approx(player.velocity.x):
flip_h = player.velocity.x < 0


# TODO: Can we make Champ swim in a more interesting pattern?
# Can we change the way Champ swims vertically? Can we accelerate?

# Continues to move the CharacterBody2D Object based on it's velocity
move_and_slide()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://ctkcxtbfh6pwf
43 changes: 38 additions & 5 deletions scenes/quests/story_quests/champ/4_outro/champ_outro.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
[gd_scene load_steps=7 format=4 uid="uid://bbjh0yoqbchuo"]
[gd_scene load_steps=10 format=4 uid="uid://bbjh0yoqbchuo"]

[ext_resource type="PackedScene" uid="uid://cfcgrfvtn04yp" path="res://scenes/ui_elements/hud/hud.tscn" id="1_x48x5"]
[ext_resource type="SpriteFrames" uid="uid://ctjbkxw0r2f2i" path="res://scenes/quests/story_quests/champ/player_components/champ_player.tres" id="3_276wt"]
[ext_resource type="TileSet" uid="uid://bo4jyvl3lcww1" path="res://scenes/quests/story_quests/champ/champ_tileset.tres" id="3_o5ika"]
[ext_resource type="Script" uid="uid://x1mxt6bmei2o" path="res://scenes/ui_elements/cinematic/cinematic.gd" id="4_jdkp3"]
[ext_resource type="Resource" uid="uid://cwp3r5nyfb0bf" path="res://scenes/quests/story_quests/champ/4_outro/outro_components/champ_outro.dialogue" id="5_f2mqr"]
[ext_resource type="Texture2D" uid="uid://b1knp31rwuxpq" path="res://scenes/quests/story_quests/champ/tiles/assets/blank_champ.png" id="7_276wt"]
[ext_resource type="Script" uid="uid://ctkcxtbfh6pwf" path="res://scenes/quests/story_quests/champ/4_outro/champ_animation.gd" id="7_jdkp3"]

[sub_resource type="CircleShape2D" id="CircleShape2D_f2mqr"]

[sub_resource type="SpriteFrames" id="SpriteFrames_6d3de"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("7_276wt")
}, {
"duration": 1.0,
"texture": ExtResource("7_276wt")
}, {
Comment on lines +15 to +21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference you could have one frame at 2× length rather than duplicating the frame:

Image

"duration": 1.0,
"texture": null
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]

[node name="Outro" type="Node2D"]

Expand Down Expand Up @@ -44,7 +64,20 @@ dialogue = ExtResource("5_f2mqr")
next_scene = "uid://cufkthb25mpxy"
metadata/_custom_type_script = "uid://x1mxt6bmei2o"

[node name="BlankChamp" type="Sprite2D" parent="."]
position = Vector2(746.75006, 173.74997)
scale = Vector2(2.003906, 2.003906)
texture = ExtResource("7_276wt")
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
script = ExtResource("7_jdkp3")

[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
shape = SubResource("CircleShape2D_f2mqr")

[node name="Label" type="Label" parent="CharacterBody2D"]
offset_left = 305.0
offset_top = 161.0
offset_right = 409.0
offset_bottom = 184.0
text = "Animate me!"

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="CharacterBody2D"]
position = Vector2(372, 151)
sprite_frames = SubResource("SpriteFrames_6d3de")
autoplay = "default"