added player char animated idle sprite

This commit is contained in:
array-in-a-matrix 2023-09-29 12:39:03 -04:00
parent 760bb07104
commit 9a20c08c92
4 changed files with 67 additions and 11 deletions

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://h23p3so20mul"]
[gd_scene load_steps=5 format=3 uid="uid://h23p3so20mul"]
[ext_resource type="Texture2D" uid="uid://du5806g41q65h" path="res://res/Pixel Crawler - FREE - 1.8/Environment/Dungeon Prison/Assets/Tiles.png" id="1_hw42u"]
[ext_resource type="PackedScene" uid="uid://octr5yng0fvm" path="res://player/player.tscn" id="2_5ejup"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_fcq2a"]
texture = ExtResource("1_hw42u")
@ -994,6 +995,11 @@ sources/0 = SubResource("TileSetAtlasSource_fcq2a")
[node name="s_1" type="Node2D"]
[node name="tile_map" type="TileMap" parent="."]
position = Vector2(0, 1)
tile_set = SubResource("TileSet_7m7cm")
format = 2
layer_0/name = "wall"
layer_0/tile_data = PackedInt32Array(0, 196608, 4, 65536, 196608, 5, 131072, 196608, 5, 196608, 196608, 5, 262144, 196608, 5, 327680, 196608, 5, 393216, 196608, 5, 458752, 196608, 5, 1, 0, 0, 65537, 0, 1, 131073, 0, 2, 2, 65536, 0, 65538, 65536, 1, 131074, 65536, 2, 3, 65536, 0, 65539, 65536, 1, 131075, 65536, 2, 4, 65536, 0, 65540, 65536, 1, 131076, 65536, 2, 5, 65536, 0, 65541, 65536, 1, 131077, 65536, 2, 6, 65536, 0, 65542, 65536, 1, 131078, 65536, 2, 7, 65536, 0, 65543, 65536, 1, 131079, 65536, 2, 8, 65536, 0, 65544, 65536, 1, 131080, 65536, 2, 9, 65536, 0, 65545, 65536, 1, 131081, 65536, 2, 10, 65536, 0, 65546, 65536, 1, 131082, 65536, 2, 11, 65536, 0, 65547, 65536, 1, 131083, 65536, 2, 12, 65536, 0, 65548, 65536, 1, 131084, 65536, 2, 13, 131072, 0, 65549, 131072, 1, 131085, 131072, 2, 14, 262144, 4, 65550, 262144, 5, 131086, 262144, 5, 196622, 262144, 5, 262158, 262144, 5, 327694, 262144, 5, 393230, 262144, 5, 458766, 262144, 5, 524302, 262144, 6, 524301, 65536, 3, 524300, 65536, 3, 524299, 65536, 3, 524298, 65536, 3, 524297, 65536, 3, 524296, 65536, 3, 524295, 65536, 3, 524294, 65536, 3, 524293, 65536, 3, 524292, 65536, 3, 524291, 65536, 3, 524290, 65536, 3, 524289, 65536, 3, 524288, 196608, 6, 196609, 262144, 0, 196610, 327680, 0, 196611, 327680, 0, 196612, 327680, 0, 196613, 327680, 0, 196614, 327680, 0, 196615, 327680, 0, 196616, 327680, 0, 196617, 327680, 0, 196618, 327680, 0, 196619, 327680, 0, 196620, 327680, 0, 262156, 327680, 1, 327692, 327680, 1, 393228, 327680, 1, 393227, 327680, 1, 393226, 327680, 1, 393225, 327680, 1, 393224, 327680, 1, 393223, 327680, 1, 393222, 327680, 1, 393221, 327680, 1, 393220, 327680, 1, 393219, 327680, 1, 393218, 327680, 1, 327682, 327680, 1, 262146, 327680, 1, 262147, 327680, 1, 327683, 327680, 1, 327684, 327680, 1, 327685, 327680, 1, 327686, 327680, 1, 327687, 327680, 1, 327688, 327680, 1, 327689, 327680, 1, 327690, 327680, 1, 327691, 327680, 1, 262155, 327680, 1, 262154, 327680, 1, 262153, 327680, 1, 262152, 327680, 1, 262151, 327680, 1, 262150, 327680, 1, 262149, 327680, 1, 262148, 327680, 1, 196621, 393216, 0, 262157, 393216, 1, 327693, 393216, 1, 393229, 393216, 1, 458765, 393216, 2, 458764, 327680, 2, 458763, 327680, 2, 458762, 327680, 2, 458761, 327680, 2, 458760, 327680, 2, 458759, 327680, 2, 458758, 327680, 2, 458757, 327680, 2, 458756, 327680, 2, 458755, 327680, 2, 458754, 327680, 2, 262145, 262144, 1, 327681, 262144, 1, 393217, 262144, 1, 458753, 262144, 2)
[node name="player" parent="." instance=ExtResource("2_5ejup")]
position = Vector2(76, 85)

View file

@ -1,5 +1,7 @@
extends CharacterBody2D
@onready var animated_sprite: AnimatedSprite2D = $animated_sprite_2d
func _physics_process(delta):
velocity = Vector2()
if Input.is_key_pressed(KEY_A) || Input.is_key_pressed(KEY_LEFT):
@ -10,6 +12,10 @@ func _physics_process(delta):
velocity.y += 1
if Input.is_key_pressed(KEY_D) || Input.is_key_pressed(KEY_RIGHT):
velocity.x += 1
velocity *= 300
velocity *= 150
move_and_slide()
update_animation()
func update_animation():
animated_sprite.play("idle")

View file

@ -1,19 +1,62 @@
[gd_scene load_steps=4 format=3 uid="uid://octr5yng0fvm"]
[gd_scene load_steps=9 format=3 uid="uid://octr5yng0fvm"]
[ext_resource type="Script" path="res://player/player.gd" id="1_f1igx"]
[ext_resource type="Texture2D" uid="uid://crm0rryg1syha" path="res://res/test-player.png" id="2_5nav2"]
[ext_resource type="Texture2D" uid="uid://d3r2qikkn7kh7" path="res://res/Pixel Crawler - FREE - 1.8/Heroes/Knight/Idle/Idle-Sheet.png" id="2_m3335"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4f40j"]
size = Vector2(100, 100)
[sub_resource type="AtlasTexture" id="AtlasTexture_4mqlh"]
atlas = ExtResource("2_m3335")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_t16cw"]
atlas = ExtResource("2_m3335")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_525ge"]
atlas = ExtResource("2_m3335")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_wu0a1"]
atlas = ExtResource("2_m3335")
region = Rect2(96, 0, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_1fns6"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_4mqlh")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_t16cw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_525ge")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wu0a1")
}],
"loop": true,
"name": &"idle",
"speed": 5.0
}]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mp7ql"]
size = Vector2(19, 29)
[node name="player" type="CharacterBody2D"]
script = ExtResource("1_f1igx")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("2_5nav2")
[node name="animated_sprite_2d" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_1fns6")
animation = &"idle"
frame_progress = 0.512506
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_4f40j")
[node name="collision_shape_2d" type="CollisionShape2D" parent="."]
position = Vector2(-1.5, 1.5)
shape = SubResource("RectangleShape2D_mp7ql")
[node name="Camera2D" type="Camera2D" parent="."]
zoom = Vector2(3, 3)
process_callback = 0
limit_smoothed = true
drag_horizontal_enabled = true
drag_vertical_enabled = true

View file

@ -28,4 +28,5 @@ naming/node_name_casing=2
[rendering]
textures/canvas_textures/default_texture_filter=0
renderer/rendering_method="mobile"