From e04ae6276e9297c15d6efcbb8a266c1df3216346 Mon Sep 17 00:00:00 2001 From: Kellan KOZUME Date: Mon, 13 Apr 2026 22:40:42 -0400 Subject: [PATCH] feat: add player controller --- .gitignore | 1 + entities/player/player.gd | 45 ++ entities/player/player.tscn | 863 ++++++++++++++++++++++++++++++++++++ project.godot | 40 ++ tests/main.tscn | 7 + tests/main_test.gd | 1 + tests/main_test.gd.uid | 1 + 7 files changed, 958 insertions(+) create mode 100644 tests/main_test.gd create mode 100644 tests/main_test.gd.uid diff --git a/.gitignore b/.gitignore index d2d0f4d..95d8133 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ export_presets.cfg +tests/assets/ \ No newline at end of file diff --git a/entities/player/player.gd b/entities/player/player.gd index e69de29..9ffb842 100644 --- a/entities/player/player.gd +++ b/entities/player/player.gd @@ -0,0 +1,45 @@ +extends CharacterBody2D + +const SPEED := 64.0 + +@onready var sprite := $AnimatedSprite2D +@onready var interaction_area := $InteractionArea + +var last_direction := Vector2.DOWN +var interactable : Node = null + +func _physics_process(_delta: float) -> void: + var direction := Input.get_vector( + "move_left", "move_right", "move_up", "move_down" + ) + + velocity = direction * SPEED + move_and_slide() + _update_animation(direction) + +func _unhandled_input(event: InputEvent) -> void: + if event.is_action_pressed("interact") and interactable: + interactable.interact() + +# --- Animation --- +func _update_animation(direction: Vector2) -> void: + if direction != Vector2.ZERO: + last_direction = direction + sprite.play("walk_" + _dir_name(direction)) + else: + sprite.play("idle_" + _dir_name(last_direction)) + +func _dir_name(dir: Vector2) -> String: + if abs(dir.x) > abs(dir.y): + return "right" if dir.x > 0 else "left" + else: + return "down" if dir.y > 0 else "up" + +# --- Interaction --- +func _on_interaction_area_body_entered(body: Node) -> void: + if body.has_method("interact"): + interactable = body + +func _on_interaction_area_body_exited(body: Node) -> void: + if body == interactable: + interactable = null diff --git a/entities/player/player.tscn b/entities/player/player.tscn index de7eab8..cbd4732 100644 --- a/entities/player/player.tscn +++ b/entities/player/player.tscn @@ -1,3 +1,866 @@ [gd_scene format=3 uid="uid://mh3msmluve7p"] +[ext_resource type="Texture2D" uid="uid://tv4tac24mp7m" path="res://tests/assets/sprites/player/Idle/Knight_Idle_down.png" id="1_bls4j"] +[ext_resource type="Script" uid="uid://tuwu6hmfun0e" path="res://entities/player/player.gd" id="1_fkugw"] +[ext_resource type="Texture2D" uid="uid://bu8vhohnef0d6" path="res://tests/assets/sprites/player/Idle/Knight_Idle_left.png" id="2_fkugw"] +[ext_resource type="Texture2D" uid="uid://cxgxjceocigs7" path="res://tests/assets/sprites/player/Idle/Knight_Idle_right.png" id="3_8fjmc"] +[ext_resource type="Texture2D" uid="uid://dxg7gb7rp55mg" path="res://tests/assets/sprites/player/Idle/Knight_Idle_up.png" id="4_qiwj3"] +[ext_resource type="Texture2D" uid="uid://crl6auvtk8cuv" path="res://tests/assets/sprites/player/Walk/Knight_Walk_down.png" id="6_bectd"] +[ext_resource type="Texture2D" uid="uid://bcpype0l04sji" path="res://tests/assets/sprites/player/Walk/Knight_Walk_left.png" id="7_wvtmh"] +[ext_resource type="Texture2D" uid="uid://vk532d3hf3qb" path="res://tests/assets/sprites/player/Walk/Knight_Walk_right.png" id="8_7thud"] +[ext_resource type="Texture2D" uid="uid://dq64eyyv5tiow" path="res://tests/assets/sprites/player/Walk/Knight_Walk_up.png" id="9_a1qjk"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_26q78"] +radius = 15.0 +height = 44.0 + +[sub_resource type="AtlasTexture" id="AtlasTexture_bectd"] +atlas = ExtResource("1_bls4j") +region = Rect2(0, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wvtmh"] +atlas = ExtResource("1_bls4j") +region = Rect2(256, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7thud"] +atlas = ExtResource("1_bls4j") +region = Rect2(512, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_a1qjk"] +atlas = ExtResource("1_bls4j") +region = Rect2(768, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_j3ovn"] +atlas = ExtResource("1_bls4j") +region = Rect2(1024, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_afbqv"] +atlas = ExtResource("1_bls4j") +region = Rect2(0, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gx6sm"] +atlas = ExtResource("1_bls4j") +region = Rect2(256, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yqrof"] +atlas = ExtResource("1_bls4j") +region = Rect2(512, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_3wlsy"] +atlas = ExtResource("1_bls4j") +region = Rect2(768, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_b2kln"] +atlas = ExtResource("1_bls4j") +region = Rect2(1024, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_we0b7"] +atlas = ExtResource("1_bls4j") +region = Rect2(0, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mtric"] +atlas = ExtResource("1_bls4j") +region = Rect2(256, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_eyb6c"] +atlas = ExtResource("1_bls4j") +region = Rect2(512, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_221hk"] +atlas = ExtResource("1_bls4j") +region = Rect2(768, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ghoj8"] +atlas = ExtResource("1_bls4j") +region = Rect2(1024, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_t1t22"] +atlas = ExtResource("1_bls4j") +region = Rect2(0, 768, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_50fht"] +atlas = ExtResource("1_bls4j") +region = Rect2(256, 768, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wuv6x"] +atlas = ExtResource("2_fkugw") +region = Rect2(0, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qpopc"] +atlas = ExtResource("2_fkugw") +region = Rect2(256, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wq0jh"] +atlas = ExtResource("2_fkugw") +region = Rect2(512, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gt4e4"] +atlas = ExtResource("2_fkugw") +region = Rect2(768, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_24ehl"] +atlas = ExtResource("2_fkugw") +region = Rect2(1024, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bwdx1"] +atlas = ExtResource("2_fkugw") +region = Rect2(0, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vewsg"] +atlas = ExtResource("2_fkugw") +region = Rect2(256, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2soq1"] +atlas = ExtResource("2_fkugw") +region = Rect2(512, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8q4fm"] +atlas = ExtResource("2_fkugw") +region = Rect2(768, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_np63p"] +atlas = ExtResource("2_fkugw") +region = Rect2(1024, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0eo6o"] +atlas = ExtResource("2_fkugw") +region = Rect2(0, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ttr27"] +atlas = ExtResource("2_fkugw") +region = Rect2(256, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_13wue"] +atlas = ExtResource("2_fkugw") +region = Rect2(512, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wy7bt"] +atlas = ExtResource("2_fkugw") +region = Rect2(768, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_geky7"] +atlas = ExtResource("2_fkugw") +region = Rect2(1024, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qwspa"] +atlas = ExtResource("2_fkugw") +region = Rect2(0, 768, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_r633c"] +atlas = ExtResource("2_fkugw") +region = Rect2(256, 768, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pacje"] +atlas = ExtResource("3_8fjmc") +region = Rect2(0, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2h0qb"] +atlas = ExtResource("3_8fjmc") +region = Rect2(256, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mmk7k"] +atlas = ExtResource("3_8fjmc") +region = Rect2(512, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_g3pa7"] +atlas = ExtResource("3_8fjmc") +region = Rect2(768, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7otdo"] +atlas = ExtResource("3_8fjmc") +region = Rect2(1024, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_c112w"] +atlas = ExtResource("3_8fjmc") +region = Rect2(0, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_u37te"] +atlas = ExtResource("3_8fjmc") +region = Rect2(256, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ssgi7"] +atlas = ExtResource("3_8fjmc") +region = Rect2(512, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rtlkk"] +atlas = ExtResource("3_8fjmc") +region = Rect2(768, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_a2brg"] +atlas = ExtResource("3_8fjmc") +region = Rect2(1024, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_arp52"] +atlas = ExtResource("3_8fjmc") +region = Rect2(0, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_jjk8f"] +atlas = ExtResource("3_8fjmc") +region = Rect2(256, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cnswy"] +atlas = ExtResource("3_8fjmc") +region = Rect2(512, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_q5bfg"] +atlas = ExtResource("3_8fjmc") +region = Rect2(768, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_p22ii"] +atlas = ExtResource("3_8fjmc") +region = Rect2(1024, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7rgwd"] +atlas = ExtResource("3_8fjmc") +region = Rect2(0, 768, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_24so6"] +atlas = ExtResource("3_8fjmc") +region = Rect2(256, 768, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sk710"] +atlas = ExtResource("4_qiwj3") +region = Rect2(0, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_kbbq5"] +atlas = ExtResource("4_qiwj3") +region = Rect2(256, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_akixf"] +atlas = ExtResource("4_qiwj3") +region = Rect2(512, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_3y563"] +atlas = ExtResource("4_qiwj3") +region = Rect2(768, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sgfia"] +atlas = ExtResource("4_qiwj3") +region = Rect2(1024, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sv458"] +atlas = ExtResource("4_qiwj3") +region = Rect2(0, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pth52"] +atlas = ExtResource("4_qiwj3") +region = Rect2(256, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4iu2e"] +atlas = ExtResource("4_qiwj3") +region = Rect2(512, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0q7bw"] +atlas = ExtResource("4_qiwj3") +region = Rect2(768, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qb5t2"] +atlas = ExtResource("4_qiwj3") +region = Rect2(1024, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qsjf6"] +atlas = ExtResource("4_qiwj3") +region = Rect2(0, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_k3n4f"] +atlas = ExtResource("4_qiwj3") +region = Rect2(256, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gmffv"] +atlas = ExtResource("4_qiwj3") +region = Rect2(512, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rqau1"] +atlas = ExtResource("4_qiwj3") +region = Rect2(768, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gv6fn"] +atlas = ExtResource("4_qiwj3") +region = Rect2(1024, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2vqvu"] +atlas = ExtResource("4_qiwj3") +region = Rect2(0, 768, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yb4xh"] +atlas = ExtResource("4_qiwj3") +region = Rect2(256, 768, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ix1gt"] +atlas = ExtResource("6_bectd") +region = Rect2(0, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sym6v"] +atlas = ExtResource("6_bectd") +region = Rect2(256, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dnai7"] +atlas = ExtResource("6_bectd") +region = Rect2(512, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_u8til"] +atlas = ExtResource("6_bectd") +region = Rect2(768, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qydng"] +atlas = ExtResource("6_bectd") +region = Rect2(0, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1bn7s"] +atlas = ExtResource("6_bectd") +region = Rect2(256, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_aerxn"] +atlas = ExtResource("6_bectd") +region = Rect2(512, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qd1uy"] +atlas = ExtResource("6_bectd") +region = Rect2(768, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_fs2ga"] +atlas = ExtResource("6_bectd") +region = Rect2(0, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_kvro1"] +atlas = ExtResource("6_bectd") +region = Rect2(256, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cnghg"] +atlas = ExtResource("6_bectd") +region = Rect2(512, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8xphj"] +atlas = ExtResource("7_wvtmh") +region = Rect2(0, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_6v113"] +atlas = ExtResource("7_wvtmh") +region = Rect2(256, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_6t5pu"] +atlas = ExtResource("7_wvtmh") +region = Rect2(512, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_81y5a"] +atlas = ExtResource("7_wvtmh") +region = Rect2(768, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bwbc3"] +atlas = ExtResource("7_wvtmh") +region = Rect2(0, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_b21vv"] +atlas = ExtResource("7_wvtmh") +region = Rect2(256, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vwpi8"] +atlas = ExtResource("7_wvtmh") +region = Rect2(512, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nf7d4"] +atlas = ExtResource("7_wvtmh") +region = Rect2(768, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_xgwqa"] +atlas = ExtResource("7_wvtmh") +region = Rect2(0, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_6tg0t"] +atlas = ExtResource("7_wvtmh") +region = Rect2(256, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vq0gh"] +atlas = ExtResource("7_wvtmh") +region = Rect2(512, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_kpbfg"] +atlas = ExtResource("8_7thud") +region = Rect2(0, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_52mt1"] +atlas = ExtResource("8_7thud") +region = Rect2(256, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1wqwd"] +atlas = ExtResource("8_7thud") +region = Rect2(512, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_lolo7"] +atlas = ExtResource("8_7thud") +region = Rect2(768, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_btle8"] +atlas = ExtResource("8_7thud") +region = Rect2(0, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_fp3no"] +atlas = ExtResource("8_7thud") +region = Rect2(256, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_v8xka"] +atlas = ExtResource("8_7thud") +region = Rect2(512, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mh54n"] +atlas = ExtResource("8_7thud") +region = Rect2(768, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ulahl"] +atlas = ExtResource("8_7thud") +region = Rect2(0, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qb5o2"] +atlas = ExtResource("8_7thud") +region = Rect2(256, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_x41hg"] +atlas = ExtResource("8_7thud") +region = Rect2(512, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_041m2"] +atlas = ExtResource("9_a1qjk") +region = Rect2(0, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_eiyfn"] +atlas = ExtResource("9_a1qjk") +region = Rect2(256, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dks87"] +atlas = ExtResource("9_a1qjk") +region = Rect2(512, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vmmfi"] +atlas = ExtResource("9_a1qjk") +region = Rect2(768, 0, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cskxj"] +atlas = ExtResource("9_a1qjk") +region = Rect2(0, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_o466o"] +atlas = ExtResource("9_a1qjk") +region = Rect2(256, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_n41sh"] +atlas = ExtResource("9_a1qjk") +region = Rect2(512, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rockh"] +atlas = ExtResource("9_a1qjk") +region = Rect2(768, 256, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_agi6m"] +atlas = ExtResource("9_a1qjk") +region = Rect2(0, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_t4h4b"] +atlas = ExtResource("9_a1qjk") +region = Rect2(256, 512, 256, 256) + +[sub_resource type="AtlasTexture" id="AtlasTexture_crtd3"] +atlas = ExtResource("9_a1qjk") +region = Rect2(512, 512, 256, 256) + +[sub_resource type="SpriteFrames" id="SpriteFrames_ix1gt"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_bectd") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wvtmh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7thud") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_a1qjk") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_j3ovn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_afbqv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gx6sm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yqrof") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_3wlsy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_b2kln") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_we0b7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mtric") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_eyb6c") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_221hk") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ghoj8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_t1t22") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_50fht") +}], +"loop": true, +"name": &"idle_down", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_wuv6x") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qpopc") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wq0jh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gt4e4") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_24ehl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bwdx1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vewsg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_2soq1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8q4fm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_np63p") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0eo6o") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ttr27") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_13wue") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wy7bt") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_geky7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qwspa") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_r633c") +}], +"loop": true, +"name": &"idle_left", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_pacje") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_2h0qb") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mmk7k") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_g3pa7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7otdo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_c112w") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_u37te") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ssgi7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rtlkk") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_a2brg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_arp52") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_jjk8f") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_cnswy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_q5bfg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_p22ii") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7rgwd") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_24so6") +}], +"loop": true, +"name": &"idle_right", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_sk710") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_kbbq5") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_akixf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_3y563") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_sgfia") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_sv458") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pth52") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4iu2e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0q7bw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qb5t2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qsjf6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_k3n4f") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gmffv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rqau1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gv6fn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_2vqvu") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yb4xh") +}], +"loop": true, +"name": &"idle_up", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_ix1gt") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_sym6v") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dnai7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_u8til") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qydng") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_1bn7s") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_aerxn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qd1uy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_fs2ga") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_kvro1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_cnghg") +}], +"loop": true, +"name": &"walk_down", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_8xphj") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_6v113") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_6t5pu") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_81y5a") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bwbc3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_b21vv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vwpi8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nf7d4") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_xgwqa") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_6tg0t") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vq0gh") +}], +"loop": true, +"name": &"walk_left", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_kpbfg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_52mt1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_1wqwd") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_lolo7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_btle8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_fp3no") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_v8xka") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mh54n") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ulahl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qb5o2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_x41hg") +}], +"loop": true, +"name": &"walk_right", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_041m2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_eiyfn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dks87") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vmmfi") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_cskxj") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_o466o") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_n41sh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rockh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_agi6m") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_t4h4b") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_crtd3") +}], +"loop": true, +"name": &"walk_up", +"speed": 10.0 +}] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_bectd"] +size = Vector2(77.5, 47.5) + [node name="Player" type="Node2D" unique_id=628518902] + +[node name="CharacterBody2D" type="CharacterBody2D" parent="." unique_id=92363508] +script = ExtResource("1_fkugw") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D" unique_id=865652003] +shape = SubResource("CapsuleShape2D_26q78") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="CharacterBody2D" unique_id=1859344504] +position = Vector2(1, 7) +sprite_frames = SubResource("SpriteFrames_ix1gt") +animation = &"walk_right" +autoplay = "idle_down" + +[node name="InteractionArea" type="Area2D" parent="CharacterBody2D/AnimatedSprite2D" unique_id=22124935] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D/AnimatedSprite2D/InteractionArea" unique_id=51125783] +position = Vector2(-1, -6) +shape = SubResource("RectangleShape2D_bectd") +debug_color = Color(0.9411765, 0, 0.29411766, 0.19607843) diff --git a/project.godot b/project.godot index b1c5ffa..7397ce1 100644 --- a/project.godot +++ b/project.godot @@ -24,6 +24,46 @@ window/size/window_height_override=720 window/stretch/mode="canvas_items" window/stretch/scale_mode="integer" +[input] + +move_up={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_down={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_left={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_right={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +interact={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null) +] +} + +[layer_names] + +2d_render/layer_1="world" +2d_render/layer_2="player" +2d_render/layer_3="npc" +2d_render/layer_4="items" +2d_render/layer_5="interaction" + [physics] 3d/physics_engine="Jolt Physics" diff --git a/tests/main.tscn b/tests/main.tscn index 4aae286..a51e11c 100644 --- a/tests/main.tscn +++ b/tests/main.tscn @@ -1,13 +1,20 @@ [gd_scene format=3 uid="uid://c5lskgqkorw6v"] +[ext_resource type="Script" uid="uid://dgjqqygp6oydl" path="res://tests/main_test.gd" id="1_ctdtd"] +[ext_resource type="PackedScene" uid="uid://mh3msmluve7p" path="res://entities/player/player.tscn" id="3_pi5dy"] + [sub_resource type="LabelSettings" id="LabelSettings_wsebr"] [node name="Main" type="Node2D" unique_id=42454470] [node name="Node2D" type="Node2D" parent="." unique_id=87146710] +script = ExtResource("1_ctdtd") [node name="Label" type="Label" parent="Node2D" unique_id=1541383456] offset_right = 40.0 offset_bottom = 23.0 text = "This is a text lol" label_settings = SubResource("LabelSettings_wsebr") + +[node name="Player" parent="Node2D" unique_id=628518902 instance=ExtResource("3_pi5dy")] +position = Vector2(158, 121) diff --git a/tests/main_test.gd b/tests/main_test.gd new file mode 100644 index 0000000..e251cf8 --- /dev/null +++ b/tests/main_test.gd @@ -0,0 +1 @@ +extends Node2D diff --git a/tests/main_test.gd.uid b/tests/main_test.gd.uid new file mode 100644 index 0000000..38091a2 --- /dev/null +++ b/tests/main_test.gd.uid @@ -0,0 +1 @@ +uid://dgjqqygp6oydl