summaryrefslogtreecommitdiff
path: root/scenes/char
diff options
context:
space:
mode:
Diffstat (limited to 'scenes/char')
-rw-r--r--scenes/char/weener.gd35
-rw-r--r--scenes/char/weener.gd.uid1
-rw-r--r--scenes/char/weener.tscn101
3 files changed, 137 insertions, 0 deletions
diff --git a/scenes/char/weener.gd b/scenes/char/weener.gd
new file mode 100644
index 0000000..f4f9e38
--- /dev/null
+++ b/scenes/char/weener.gd
@@ -0,0 +1,35 @@
+extends CharacterBody2D
+
+@onready var sprite := $Sprite
+@onready var nav2d := $NavigationAgent2D
+
+const ref_speed := 500.0
+@onready var speed := ref_speed
+@onready var target := position
+
+func _physics_process(delta: float) -> void:
+ set_target()
+ navigate(delta)
+
+
+func set_target() -> void:
+ if Input.is_action_just_pressed("set_target"):
+ nav2d.target_position = get_global_mouse_position()
+ if position.distance_to(nav2d.target_position) > 750:
+ speed = ref_speed * 1.8
+ else:
+ speed = ref_speed
+
+
+func navigate(delta: float) -> void:
+ if nav2d.is_navigation_finished():
+ sprite.play("stand")
+ return
+ var next_path_position: Vector2 = nav2d.get_next_path_position()
+ velocity = global_position.direction_to(next_path_position) * speed
+ sprite.flip_h = velocity.x > 0
+ position += velocity * delta
+ if speed > ref_speed:
+ sprite.play("run")
+ else:
+ sprite.play("walk")
diff --git a/scenes/char/weener.gd.uid b/scenes/char/weener.gd.uid
new file mode 100644
index 0000000..170ef28
--- /dev/null
+++ b/scenes/char/weener.gd.uid
@@ -0,0 +1 @@
+uid://bmudq0wqybjnw
diff --git a/scenes/char/weener.tscn b/scenes/char/weener.tscn
new file mode 100644
index 0000000..c8164fe
--- /dev/null
+++ b/scenes/char/weener.tscn
@@ -0,0 +1,101 @@
+[gd_scene format=3 uid="uid://bt4utdbe577mj"]
+
+[ext_resource type="Script" uid="uid://bmudq0wqybjnw" path="res://scenes/char/weener.gd" id="1_5hljh"]
+[ext_resource type="Texture2D" uid="uid://bje5rius281oi" path="res://spr/weener/crouch.png" id="1_6smxx"]
+[ext_resource type="Texture2D" uid="uid://dk3ulxm2i0qm6" path="res://spr/weener/stand.png" id="1_b3dvs"]
+[ext_resource type="Texture2D" uid="uid://cr80vs56knlqh" path="res://spr/weener/grab.png" id="1_ka3oh"]
+[ext_resource type="Texture2D" uid="uid://bbcs52esee2pt" path="res://spr/weener/walk.png" id="2_tfg2r"]
+[ext_resource type="Texture2D" uid="uid://b1bn5hf6uxfiw" path="res://spr/weener/run1.png" id="5_rsd08"]
+[ext_resource type="Texture2D" uid="uid://0pued7jac5i2" path="res://spr/weener/run2.png" id="6_xgxdw"]
+
+[sub_resource type="SpriteFrames" id="SpriteFrames_ka3oh"]
+animations = [{
+"frames": [{
+"duration": 1.0,
+"texture": ExtResource("1_6smxx")
+}],
+"loop": true,
+"name": &"crouch",
+"speed": 5.0
+}, {
+"frames": [{
+"duration": 1.0,
+"texture": ExtResource("1_ka3oh")
+}, {
+"duration": 1.0,
+"texture": ExtResource("1_b3dvs")
+}, {
+"duration": 1.0,
+"texture": ExtResource("1_b3dvs")
+}],
+"loop": false,
+"name": &"grab",
+"speed": 2.0
+}, {
+"frames": [{
+"duration": 1.0,
+"texture": ExtResource("5_rsd08")
+}, {
+"duration": 1.0,
+"texture": ExtResource("1_b3dvs")
+}, {
+"duration": 1.0,
+"texture": ExtResource("6_xgxdw")
+}, {
+"duration": 1.0,
+"texture": ExtResource("1_b3dvs")
+}],
+"loop": true,
+"name": &"run",
+"speed": 5.0
+}, {
+"frames": [{
+"duration": 1.0,
+"texture": ExtResource("1_b3dvs")
+}],
+"loop": false,
+"name": &"stand",
+"speed": 5.0
+}, {
+"frames": [{
+"duration": 1.0,
+"texture": ExtResource("2_tfg2r")
+}, {
+"duration": 1.0,
+"texture": ExtResource("1_b3dvs")
+}],
+"loop": true,
+"name": &"walk",
+"speed": 3.0
+}]
+
+[sub_resource type="RectangleShape2D" id="RectangleShape2D_rsd08"]
+size = Vector2(44, 109.5)
+
+[node name="Weener" type="CharacterBody2D" unique_id=1834042649]
+script = ExtResource("1_5hljh")
+
+[node name="Sprite" type="AnimatedSprite2D" parent="." unique_id=918466208]
+position = Vector2(0, -190)
+sprite_frames = SubResource("SpriteFrames_ka3oh")
+animation = &"stand"
+autoplay = "stand"
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1548923938]
+rotation = 1.5707964
+shape = SubResource("RectangleShape2D_rsd08")
+
+[node name="NavigationAgent2D" type="NavigationAgent2D" parent="." unique_id=2038637548]
+debug_enabled = true
+
+[node name="Debug" type="Label" parent="." unique_id=999070759]
+visible = false
+anchors_preset = 5
+anchor_left = 0.5
+anchor_right = 0.5
+offset_left = -20.0
+offset_top = -502.0
+offset_right = 20.0
+offset_bottom = -479.0
+grow_horizontal = 2
+size_flags_vertical = 0