diff --git a/src/models/enemies/trash_can/sprites/trash_can.png b/src/models/enemies/trash_can/sprites/trash_can.png deleted file mode 100644 index 722a164..0000000 Binary files a/src/models/enemies/trash_can/sprites/trash_can.png and /dev/null differ diff --git a/src/models/enemies/trash_can/sprites/trash_can.png.import b/src/models/enemies/trash_can/sprites/trash_can.png.import deleted file mode 100644 index 7026c89..0000000 --- a/src/models/enemies/trash_can/sprites/trash_can.png.import +++ /dev/null @@ -1,35 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/trash_can.png-0987d8f67e93f5b32fac39729f87305a.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://src/models/enemies/trash_can/sprites/trash_can.png" -dest_files=[ "res://.import/trash_can.png-0987d8f67e93f5b32fac39729f87305a.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=false -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=false -svg/scale=1.0 diff --git a/src/models/player/Player.tscn b/src/models/player/Player.tscn index dbb1d8f..c1a8aab 100644 --- a/src/models/player/Player.tscn +++ b/src/models/player/Player.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=8 format=2] -[ext_resource path="res://src/models/player/sprite.png" type="Texture" id=1] +[ext_resource path="res://src/models/player/sprites/player_spriteframes.tres" type="SpriteFrames" id=1] [ext_resource path="res://src/models/player/player.gd" type="Script" id=2] [ext_resource path="res://res/shaders/colorize.tres" type="Material" id=3] @@ -69,9 +69,11 @@ tracks/1/keys = { [node name="Player" type="KinematicBody2D" groups=["player"]] script = ExtResource( 2 ) -[node name="Sprite" type="Sprite" parent="."] +[node name="Sprite" type="AnimatedSprite" parent="."] material = ExtResource( 3 ) -texture = ExtResource( 1 ) +frames = ExtResource( 1 ) +animation = "idle" +playing = true centered = false [node name="WallCollision" type="CollisionShape2D" parent="."] diff --git a/src/models/player/player.gd b/src/models/player/player.gd index a721dee..0d50d8e 100644 --- a/src/models/player/player.gd +++ b/src/models/player/player.gd @@ -37,11 +37,6 @@ func draw_dashed_line(from, to, color, width, dash_length = 4, cap_end = false, if cap_end: draw_line(segment_start, to, color, width, antialiased) -func _process(_delta): - if Input.is_action_just_pressed("shoot"): - _shoot() - update() - func get_input(): var input_direction = Input.get_vector("left", "right", "up", "down") velocity = input_direction * speed @@ -77,6 +72,15 @@ func _draw(): var dist2enemy = position.distance_to(target.global_position) draw_dashed_line(Vector2(12, 12), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"), 1) +func _process(_delta): + $Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run") + if abs(velocity.x) > 10: + $Sprite.flip_h = true if velocity.x < 0 else false + + if Input.is_action_just_pressed("shoot"): + _shoot() + update() + func _physics_process(delta): get_input() diff --git a/src/models/player/sprite.png b/src/models/player/sprite.png deleted file mode 100644 index ae4a661..0000000 Binary files a/src/models/player/sprite.png and /dev/null differ diff --git a/src/models/player/sprites/player_spriteframes.tres b/src/models/player/sprites/player_spriteframes.tres new file mode 100644 index 0000000..05d506d --- /dev/null +++ b/src/models/player/sprites/player_spriteframes.tres @@ -0,0 +1,44 @@ +[gd_resource type="SpriteFrames" load_steps=9 format=2] + +[ext_resource path="res://src/models/player/sprites/run.png" type="Texture" id=1] + +[sub_resource type="AtlasTexture" id=7] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 22, 25 ) + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 22, 25 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 1 ) +region = Rect2( 22, 0, 22, 25 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 1 ) +region = Rect2( 44, 0, 22, 25 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 1 ) +region = Rect2( 66, 0, 22, 25 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = ExtResource( 1 ) +region = Rect2( 88, 0, 22, 25 ) + +[sub_resource type="AtlasTexture" id=6] +atlas = ExtResource( 1 ) +region = Rect2( 110, 0, 22, 25 ) + +[resource] +animations = [ { +"frames": [ SubResource( 7 ) ], +"loop": true, +"name": "idle", +"speed": 0.0 +}, { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ], +"loop": true, +"name": "run", +"speed": 12.0 +} ] diff --git a/src/models/player/sprites/run.png b/src/models/player/sprites/run.png new file mode 100644 index 0000000..bafe64e Binary files /dev/null and b/src/models/player/sprites/run.png differ diff --git a/src/models/player/sprite.png.import b/src/models/player/sprites/run.png.import similarity index 71% rename from src/models/player/sprite.png.import rename to src/models/player/sprites/run.png.import index 878c8db..0f3acc1 100644 --- a/src/models/player/sprite.png.import +++ b/src/models/player/sprites/run.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/sprite.png-d1a953a55fa409c61c2d0834450a9346.stex" +path="res://.import/run.png-345781115512817e4a25318657a4c97e.stex" metadata={ "vram_texture": false } [deps] -source_file="res://src/models/player/sprite.png" -dest_files=[ "res://.import/sprite.png-d1a953a55fa409c61c2d0834450a9346.stex" ] +source_file="res://src/models/player/sprites/run.png" +dest_files=[ "res://.import/run.png-345781115512817e4a25318657a4c97e.stex" ] [params]