From bdde57200fe36529d4016547b0d8749d96e57ae0 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 15 Apr 2024 05:43:15 +0200 Subject: [PATCH] Update `Sheep` with sprites --- entities/sheep.gd | 3 +++ entities/sheep.tscn | 26 +++++++++++-------- .../sheep_left.png | 0 .../sheep_left.png.import | 6 ++--- .../sheep_right.png | 0 .../sheep_right.png.import | 6 ++--- 6 files changed, 24 insertions(+), 17 deletions(-) rename temp/monster_sheep_onground_left.png => entities/sheep_left.png (100%) rename temp/monster_sheep_onground_left.png.import => entities/sheep_left.png.import (67%) rename temp/monster_sheep_onground_right.png => entities/sheep_right.png (100%) rename temp/monster_sheep_onground_right.png.import => entities/sheep_right.png.import (67%) diff --git a/entities/sheep.gd b/entities/sheep.gd index 83a37a0..eab2986 100644 --- a/entities/sheep.gd +++ b/entities/sheep.gd @@ -3,6 +3,7 @@ class_name Sheep @onready var draggable: Draggable = $"Draggable" +@onready var sprite: SpriteLeftRight = $"Sprite" @onready var drag_sound: AudioStreamPlayer2D = $"Draggable/DragSound" @onready var drop_sound: AudioStreamPlayer2D = $"Draggable/DropSound" @@ -10,10 +11,12 @@ class_name Sheep func _on_move(movement: Vector2) -> void: if not draggable.being_dragged: move_and_collide(movement) + sprite.handle_move(movement) func _on_drag_move(movement: Vector2) -> void: if draggable.being_dragged: move_and_collide(movement) + sprite.handle_move(movement) func _on_draggable_dragged() -> void: drag_sound.play() diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 4b03179..8750781 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -1,36 +1,40 @@ -[gd_scene load_steps=9 format=3 uid="uid://bc2bm8lbol18w"] +[gd_scene load_steps=11 format=3 uid="uid://bc2bm8lbol18w"] [ext_resource type="Script" path="res://entities/sheep.gd" id="1_4dmll"] +[ext_resource type="Texture2D" uid="uid://iljp5yn3ehfk" path="res://entities/sheep_left.png" id="2_t13f5"] [ext_resource type="PackedScene" uid="uid://bvrxvrjlo5130" path="res://behaviours/move_towards_mouse.tscn" id="2_tfd2i"] +[ext_resource type="PackedScene" uid="uid://bxbjfev0lhwws" path="res://behaviours/sprite_left_right.tscn" id="2_xbkrm"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_8ku7r"] +[ext_resource type="Texture2D" uid="uid://cxtmas4g0v6en" path="res://entities/sheep_right.png" id="4_5qoof"] [ext_resource type="AudioStream" uid="uid://buxgivpkh8dyl" path="res://entities/drop.wav" id="4_nxjnl"] [ext_resource type="AudioStream" uid="uid://bmfscpnugaejk" path="res://entities/sheep_drag.wav" id="4_oalqu"] [ext_resource type="PackedScene" uid="uid://dfdr3e32lohq" path="res://behaviours/edible.tscn" id="6_3odsh"] [sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"] -radius = 16.0 - -[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_08frh"] +radius = 8.0 [node name="Sheep" type="CharacterBody2D"] collision_layer = 8 collision_mask = 14 script = ExtResource("1_4dmll") -[node name="Shape" type="CollisionShape2D" parent="."] -shape = SubResource("CircleShape2D_c5tcn") +[node name="Sprite" parent="." instance=ExtResource("2_xbkrm")] +scale = Vector2(2, 2) +texture = ExtResource("2_t13f5") +left_texture = ExtResource("2_t13f5") +right_texture = ExtResource("4_5qoof") -[node name="Sprite" type="Sprite2D" parent="."] -scale = Vector2(32, 32) -texture = SubResource("PlaceholderTexture2D_08frh") +[node name="Shape" type="CollisionShape2D" parent="."] +scale = Vector2(3, 3) +shape = SubResource("CircleShape2D_c5tcn") [node name="MoveTowardsMouse" parent="." instance=ExtResource("2_tfd2i")] scale = Vector2(30, 30) -speed = -20.0 +speed = -30.0 can_detach = true [node name="Draggable" parent="." instance=ExtResource("3_8ku7r")] -scale = Vector2(2, 2) +scale = Vector2(3, 3) [node name="DragSound" type="AudioStreamPlayer2D" parent="Draggable"] scale = Vector2(0.5, 0.5) diff --git a/temp/monster_sheep_onground_left.png b/entities/sheep_left.png similarity index 100% rename from temp/monster_sheep_onground_left.png rename to entities/sheep_left.png diff --git a/temp/monster_sheep_onground_left.png.import b/entities/sheep_left.png.import similarity index 67% rename from temp/monster_sheep_onground_left.png.import rename to entities/sheep_left.png.import index 9cc92de..f86f3dd 100644 --- a/temp/monster_sheep_onground_left.png.import +++ b/entities/sheep_left.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://iljp5yn3ehfk" -path="res://.godot/imported/monster_sheep_onground_left.png-08d1e529839158a8ce15c655b8686183.ctex" +path="res://.godot/imported/sheep_left.png-6cb7b8ff0f6e711799b2ba3837486862.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://temp/monster_sheep_onground_left.png" -dest_files=["res://.godot/imported/monster_sheep_onground_left.png-08d1e529839158a8ce15c655b8686183.ctex"] +source_file="res://entities/sheep_left.png" +dest_files=["res://.godot/imported/sheep_left.png-6cb7b8ff0f6e711799b2ba3837486862.ctex"] [params] diff --git a/temp/monster_sheep_onground_right.png b/entities/sheep_right.png similarity index 100% rename from temp/monster_sheep_onground_right.png rename to entities/sheep_right.png diff --git a/temp/monster_sheep_onground_right.png.import b/entities/sheep_right.png.import similarity index 67% rename from temp/monster_sheep_onground_right.png.import rename to entities/sheep_right.png.import index 389d863..16b37a6 100644 --- a/temp/monster_sheep_onground_right.png.import +++ b/entities/sheep_right.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://cxtmas4g0v6en" -path="res://.godot/imported/monster_sheep_onground_right.png-010a81d06e110e85b38610fa3b9ae5de.ctex" +path="res://.godot/imported/sheep_right.png-3f6753401041e87494add5c84980155c.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://temp/monster_sheep_onground_right.png" -dest_files=["res://.godot/imported/monster_sheep_onground_right.png-010a81d06e110e85b38610fa3b9ae5de.ctex"] +source_file="res://entities/sheep_right.png" +dest_files=["res://.godot/imported/sheep_right.png-3f6753401041e87494add5c84980155c.ctex"] [params]