got four-direction movement working
This commit is contained in:
parent
f9e52d23e5
commit
5c5c510a2a
10
scenes/debug_layer.tscn
Normal file
10
scenes/debug_layer.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dgotxye77b7mr"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dy34r8x6ofyaa" path="res://scripts/debug_layer.gd" id="1_tsu2q"]
|
||||
|
||||
[node name="DebugLayer" type="CanvasLayer"]
|
||||
script = ExtResource("1_tsu2q")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://2rxue54761co" path="res://assets/1_Terrains_and_Fences_16x16.png" id="1_0xm2m"]
|
||||
[ext_resource type="Texture2D" uid="uid://srv501khyvax" path="res://assets/2_City_Terrains_16x16.png" id="2_h2yge"]
|
||||
[ext_resource type="PackedScene" uid="uid://pldxcq54fei5" path="res://scenes/new_player.tscn" id="3_h2yge"]
|
||||
[ext_resource type="PackedScene" uid="uid://pldxcq54fei5" path="res://scenes/player.tscn" id="3_h2yge"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_1bvp3"]
|
||||
texture = ExtResource("1_0xm2m")
|
||||
@ -5303,5 +5303,5 @@ sources/1 = SubResource("TileSetAtlasSource_lquwl")
|
||||
tile_map_data = PackedByteArray("AAAKAAoAAAACABIAAAAKAAkAAAACABEAAAAKAAgAAAACABEAAAAKAAcAAAACABEAAAAKAAYAAAACABEAAAAKAAUAAAACABEAAAAKAAQAAAACABEAAAAKAAMAAAACABEAAAAKAAIAAAACABEAAAAKAAEAAAACABEAAAAKAAAAAAACABAAAAAJAAoAAAABABIAAAAJAAkAAAADABIAAAAJAAgAAAABABEAAAAJAAcAAAABABEAAAAJAAYAAAABABEAAAAJAAUAAAADABIAAAAJAAQAAAADABIAAAAJAAMAAAADABIAAAAJAAIAAAADABIAAAAJAAEAAAABABEAAAAJAAAAAAABABAAAAAIAAoAAAABABIAAAAIAAkAAAABABEAAAAIAAgAAAABABEAAAAIAAcAAAABABEAAAAIAAYAAAABABEAAAAIAAUAAAADABIAAAAIAAQAAAABABEAAAAIAAMAAAABABEAAAAIAAIAAAABABEAAAAIAAEAAAADABIAAAAIAAAAAAABABAAAAAHAAoAAAABABIAAAAHAAkAAAABABEAAAAHAAgAAAADABIAAAAHAAcAAAADABIAAAAHAAYAAAADABIAAAAHAAUAAAABABEAAAAHAAQAAAABABEAAAAHAAMAAAADABIAAAAHAAIAAAADABIAAAAHAAEAAAABABEAAAAHAAAAAAABABAAAAAGAAoAAAABABIAAAAGAAkAAAABABEAAAAGAAgAAAABABEAAAAGAAcAAAABABEAAAAGAAYAAAADABIAAAAGAAUAAAABABEAAAAGAAQAAAADABIAAAAGAAMAAAABABEAAAAGAAIAAAADABIAAAAGAAEAAAADABIAAAAGAAAAAAABABAAAAAFAAoAAAABABIAAAAFAAkAAAADABIAAAAFAAgAAAABABEAAAAFAAcAAAABABEAAAAFAAYAAAADABIAAAAFAAUAAAABABEAAAAFAAQAAAADABIAAAAFAAMAAAADABIAAAAFAAIAAAABABEAAAAFAAEAAAABABEAAAAFAAAAAAABABAAAAAEAAoAAAABABIAAAAEAAkAAAABABEAAAAEAAgAAAABABEAAAAEAAcAAAABABEAAAAEAAYAAAADABIAAAAEAAUAAAADABIAAAAEAAQAAAABABEAAAAEAAMAAAADABIAAAAEAAIAAAABABEAAAAEAAEAAAADABIAAAAEAAAAAAABABAAAAADAAoAAAABABIAAAADAAkAAAADABIAAAADAAgAAAABABEAAAADAAcAAAADABIAAAADAAYAAAADABIAAAADAAUAAAADABIAAAADAAQAAAADABIAAAADAAMAAAADABIAAAADAAIAAAABABEAAAADAAEAAAADABIAAAADAAAAAAABABAAAAACAAoAAAABABIAAAACAAkAAAADABIAAAACAAgAAAADABIAAAACAAcAAAABABEAAAACAAYAAAADABIAAAACAAUAAAADABIAAAACAAQAAAADABIAAAACAAMAAAABABEAAAACAAIAAAABABEAAAACAAEAAAABABEAAAACAAAAAAABABAAAAABAAoAAAABABIAAAABAAkAAAADABIAAAABAAgAAAADABIAAAABAAcAAAABABEAAAABAAYAAAADABIAAAABAAUAAAABABEAAAABAAQAAAADABIAAAABAAMAAAADABIAAAABAAIAAAABABEAAAABAAEAAAADABIAAAABAAAAAAABABAAAAAAAAoAAAAAABIAAAAAAAkAAAAAABEAAAAAAAgAAAAAABEAAAAAAAcAAAAAABEAAAAAAAYAAAAAABEAAAAAAAUAAAAAABEAAAAAAAQAAAAAABEAAAAAAAMAAAAAABEAAAAAAAIAAAAAABEAAAAAAAEAAAAAABEAAAAAAAAAAAAAABAAAAA=")
|
||||
tile_set = SubResource("TileSet_7mycd")
|
||||
|
||||
[node name="NewPlayer" parent="." instance=ExtResource("3_h2yge")]
|
||||
speed = 100
|
||||
[node name="Player" parent="." instance=ExtResource("3_h2yge")]
|
||||
motion_mode = 1
|
||||
|
||||
@ -1,75 +0,0 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://pldxcq54fei5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ddiwahqiekcqp" path="res://scripts/new_player.gd" id="1_j1k7i"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfst1xv0quili" path="res://assets/top-down-adam-idle.png" id="1_ykc1o"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j1k7i"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(288, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tidp7"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(304, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_eotbk"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(320, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vdid1"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(336, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_40y4h"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(352, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xoay6"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(368, 0, 16, 32)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_11i01"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_j1k7i")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tidp7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_eotbk")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vdid1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_40y4h")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xoay6")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle_down",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ykc1o"]
|
||||
radius = 7.0
|
||||
height = 16.0
|
||||
|
||||
[node name="NewPlayer" type="CharacterBody2D"]
|
||||
script = ExtResource("1_j1k7i")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_11i01")
|
||||
animation = &"idle_down"
|
||||
autoplay = "idle_down"
|
||||
frame = 2
|
||||
frame_progress = 0.91331923
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 8)
|
||||
shape = SubResource("CapsuleShape2D_ykc1o")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
zoom = Vector2(4, 4)
|
||||
407
scenes/player.tscn
Normal file
407
scenes/player.tscn
Normal file
@ -0,0 +1,407 @@
|
||||
[gd_scene load_steps=55 format=3 uid="uid://pldxcq54fei5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ddiwahqiekcqp" path="res://scripts/player.gd" id="1_j1k7i"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfst1xv0quili" path="res://assets/top-down-adam-idle.png" id="1_ykc1o"]
|
||||
[ext_resource type="Texture2D" uid="uid://gxwk6kki0y1u" path="res://assets/top-down-adam-walk.png" id="3_ayngq"]
|
||||
[ext_resource type="PackedScene" uid="uid://dgotxye77b7mr" path="res://scenes/debug_layer.tscn" id="3_niqac"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j1k7i"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(288, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tidp7"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(304, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_eotbk"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(320, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vdid1"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(336, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_40y4h"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(352, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xoay6"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(368, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_arqjq"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(192, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2dryk"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(208, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_t483v"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(224, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pkuya"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(240, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_if3ei"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(256, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_v21ou"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(272, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2uj3n"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(0, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bovn1"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(16, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_0qby2"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(32, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7rew6"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(48, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jw7de"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(64, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5s4g8"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(80, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_o45cr"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(96, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4fr7e"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(112, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_b2f8q"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(128, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_v3ltj"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(144, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_44jvg"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(160, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_r14ix"]
|
||||
atlas = ExtResource("1_ykc1o")
|
||||
region = Rect2(176, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wtinw"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(288, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_h8lvs"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(304, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_e64ve"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(320, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n0gu0"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(336, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8kb50"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(352, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6q50s"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(368, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_nc4xq"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(192, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xo1yp"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(208, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ee46x"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(224, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vnedn"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(240, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ejyhw"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(256, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_m1eql"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(272, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_00hqc"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(0, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jhyaw"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(16, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tv3qk"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(32, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_81uvs"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(48, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8q122"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(64, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tqc8n"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(80, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_itr70"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(96, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jtg6r"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(112, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_0cauu"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(128, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fvj7k"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(144, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6qh68"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(160, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_h8qjx"]
|
||||
atlas = ExtResource("3_ayngq")
|
||||
region = Rect2(176, 0, 16, 32)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_11i01"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_j1k7i")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tidp7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_eotbk")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vdid1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_40y4h")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xoay6")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle_down",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_arqjq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_2dryk")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_t483v")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pkuya")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_if3ei")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_v21ou")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle_left",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_2uj3n")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bovn1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_0qby2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7rew6")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jw7de")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_5s4g8")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle_right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_o45cr")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4fr7e")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_b2f8q")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_v3ltj")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_44jvg")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_r14ix")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle_up",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_wtinw")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_h8lvs")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_e64ve")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n0gu0")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_8kb50")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_6q50s")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_down",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_nc4xq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xo1yp")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ee46x")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vnedn")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ejyhw")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_m1eql")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_left",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_00hqc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jhyaw")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tv3qk")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_81uvs")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_8q122")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tqc8n")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_itr70")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jtg6r")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_0cauu")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fvj7k")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_6qh68")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_h8qjx")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_up",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ykc1o"]
|
||||
radius = 7.0
|
||||
height = 16.0
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
script = ExtResource("1_j1k7i")
|
||||
|
||||
[node name="PlayerSprite" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_11i01")
|
||||
animation = &"walk_up"
|
||||
autoplay = "idle_down"
|
||||
|
||||
[node name="PlayerCollider" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 8)
|
||||
shape = SubResource("CapsuleShape2D_ykc1o")
|
||||
|
||||
[node name="PlayerCamera" type="Camera2D" parent="."]
|
||||
zoom = Vector2(4, 4)
|
||||
|
||||
[node name="PlayerDebug" parent="." instance=ExtResource("3_niqac")]
|
||||
variables_to_track = Array[String](["current_direction", "current_direction_string", "velocity", "input_vector"])
|
||||
16
scripts/debug_layer.gd
Normal file
16
scripts/debug_layer.gd
Normal file
@ -0,0 +1,16 @@
|
||||
@tool
|
||||
class_name DebugLayer
|
||||
extends CanvasLayer
|
||||
|
||||
@export var variables_to_track: Array[String]
|
||||
|
||||
var debug_label_scene:= preload("res://scenes/debug_label.tscn")
|
||||
|
||||
@onready var v_box_container: VBoxContainer = $VBoxContainer
|
||||
|
||||
func _ready() -> void:
|
||||
for variable in variables_to_track:
|
||||
var new_debug_label:= debug_label_scene.instantiate()
|
||||
new_debug_label.target = get_parent()
|
||||
new_debug_label.variable_name = variable
|
||||
v_box_container.add_child(new_debug_label)
|
||||
1
scripts/debug_layer.gd.uid
Normal file
1
scripts/debug_layer.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dy34r8x6ofyaa
|
||||
@ -1,28 +0,0 @@
|
||||
#@tool
|
||||
#@icon
|
||||
#class_name
|
||||
extends CharacterBody2D
|
||||
## Documentation comments
|
||||
|
||||
## Signals
|
||||
## Enums
|
||||
## Constants
|
||||
## @export variables
|
||||
@export var speed: int = 10
|
||||
## Regular variables
|
||||
var input_vector: Vector2
|
||||
## @onready variables
|
||||
|
||||
## Overridden built-in virtual methods
|
||||
#func _init() -> void:
|
||||
#func _enter_tree() -> void:
|
||||
#func _ready() -> void:
|
||||
#func _process(delta: float) -> void:
|
||||
func _physics_process(_delta: float) -> void:
|
||||
input_vector = Input.get_vector("left", "right", "up", "down")
|
||||
velocity = input_vector * speed
|
||||
move_and_slide()
|
||||
## Remaining virtual methods
|
||||
## Overridden custom methods
|
||||
## Remaining methods
|
||||
## Subclasses
|
||||
66
scripts/player.gd
Normal file
66
scripts/player.gd
Normal file
@ -0,0 +1,66 @@
|
||||
#@tool
|
||||
#@icon
|
||||
#class_name
|
||||
extends CharacterBody2D
|
||||
## Documentation comments
|
||||
|
||||
enum FaceDirection {LEFT = 0, RIGHT = 1, UP = 2, DOWN = 3}
|
||||
enum State {IDLE, WALK}
|
||||
|
||||
const SPEED: int = 48
|
||||
## @export variables
|
||||
|
||||
## Regular variables
|
||||
var current_direction: FaceDirection = FaceDirection.DOWN:
|
||||
set = set_direction
|
||||
var current_direction_string: String = "down"
|
||||
|
||||
var current_state: State = State.IDLE:
|
||||
set = set_state
|
||||
var current_state_string: String = "idle"
|
||||
|
||||
var input_vector: Vector2
|
||||
|
||||
## @onready variables
|
||||
@onready var player_sprite: AnimatedSprite2D = $PlayerSprite
|
||||
|
||||
## Overridden built-in virtual methods
|
||||
#func _init() -> void:
|
||||
#func _enter_tree() -> void:
|
||||
#func _ready() -> void:
|
||||
#func _process(delta: float) -> void:
|
||||
func _physics_process(_delta: float) -> void:
|
||||
input_vector = Vector2.ZERO
|
||||
if Input.is_action_pressed("left"):
|
||||
input_vector = Vector2.LEFT
|
||||
current_direction = FaceDirection.LEFT
|
||||
current_state = State.WALK
|
||||
elif Input.is_action_pressed("right"):
|
||||
input_vector = Vector2.RIGHT
|
||||
current_direction = FaceDirection.RIGHT
|
||||
current_state = State.WALK
|
||||
elif Input.is_action_pressed("up"):
|
||||
input_vector = Vector2.UP
|
||||
current_direction = FaceDirection.UP
|
||||
current_state = State.WALK
|
||||
elif Input.is_action_pressed("down"):
|
||||
input_vector = Vector2.DOWN
|
||||
current_direction = FaceDirection.DOWN
|
||||
current_state = State.WALK
|
||||
else: current_state = State.IDLE
|
||||
velocity = input_vector * SPEED
|
||||
move_and_slide()
|
||||
## Remaining virtual methods
|
||||
## Overridden custom methods
|
||||
## Remaining methods
|
||||
func set_direction(new_direction: FaceDirection) -> void:
|
||||
current_direction = new_direction
|
||||
current_direction_string = str(FaceDirection.keys()[new_direction]).to_lower()
|
||||
print_debug("New direction is %s" % current_direction_string)
|
||||
|
||||
func set_state(new_state: State) -> void:
|
||||
current_state = new_state
|
||||
current_state_string = str(State.keys()[new_state]).to_lower()
|
||||
var animation_string = current_state_string + "_" + current_direction_string
|
||||
player_sprite.play(animation_string)
|
||||
## Subclasses
|
||||
@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dyerg4wkjmayq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cmggbqdffjgwf" path="res://spares/player.gd" id="1_4flbx"]
|
||||
[ext_resource type="Script" uid="uid://cmggbqdffjgwf" path="res://spares/_player.gd" id="1_4flbx"]
|
||||
[ext_resource type="PackedScene" uid="uid://bsmtdok8be7d8" path="res://scenes/debug_label.tscn" id="3_i3pqv"]
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
Loading…
Reference in New Issue
Block a user