mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-22 08:04:23 +00:00
Add Imp
sprite and make it eat Sheep
This commit is contained in:
parent
bdde57200f
commit
a894aa2018
11 changed files with 108 additions and 35 deletions
|
@ -30,10 +30,8 @@ func _on_target_selected(body: Node2D) -> void:
|
||||||
func _on_target_abandoned(_body: Node2D) -> void:
|
func _on_target_abandoned(_body: Node2D) -> void:
|
||||||
move_towards.target = null
|
move_towards.target = null
|
||||||
|
|
||||||
|
|
||||||
func _on_eater_eaten(edible):
|
func _on_eater_eaten(edible):
|
||||||
eaten.emit(edible)
|
eaten.emit(edible)
|
||||||
|
|
||||||
|
|
||||||
func _on_move_towards_target_move(movement):
|
func _on_move_towards_target_move(movement):
|
||||||
move.emit(movement)
|
move.emit(movement)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://dfitiajuuvdko"]
|
[gd_scene load_steps=5 format=3 uid="uid://b7bdlh5akhi8s"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://behaviours/eat_target.gd" id="1_tlnlt"]
|
[ext_resource type="Script" path="res://behaviours/eat_target.gd" id="1_tlnlt"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dxmodn8mbvw0i" path="res://behaviours/hunt_target.tscn" id="2_c8wdv"]
|
[ext_resource type="PackedScene" uid="uid://dxmodn8mbvw0i" path="res://behaviours/hunt_target.tscn" id="2_c8wdv"]
|
||||||
|
@ -9,10 +9,11 @@
|
||||||
script = ExtResource("1_tlnlt")
|
script = ExtResource("1_tlnlt")
|
||||||
|
|
||||||
[node name="HuntTarget" parent="." instance=ExtResource("2_c8wdv")]
|
[node name="HuntTarget" parent="." instance=ExtResource("2_c8wdv")]
|
||||||
tag = &""
|
scale = Vector2(16, 16)
|
||||||
give_up_secs = 5.0
|
give_up_secs = 5.0
|
||||||
|
|
||||||
[node name="Eater" parent="." instance=ExtResource("3_ir2yh")]
|
[node name="Eater" parent="." instance=ExtResource("3_ir2yh")]
|
||||||
|
scale = Vector2(2.5, 2.5)
|
||||||
|
|
||||||
[node name="MoveTowardsTarget" parent="." instance=ExtResource("4_1qc2q")]
|
[node name="MoveTowardsTarget" parent="." instance=ExtResource("4_1qc2q")]
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,17 @@
|
||||||
[ext_resource type="Script" path="res://behaviours/eater.gd" id="1_urx5y"]
|
[ext_resource type="Script" path="res://behaviours/eater.gd" id="1_urx5y"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_61hv0"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_61hv0"]
|
||||||
radius = 16.0
|
radius = 8.0
|
||||||
|
|
||||||
[node name="Eater" type="Area2D"]
|
[node name="Eater" type="Area2D"]
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 8
|
||||||
|
monitorable = false
|
||||||
script = ExtResource("1_urx5y")
|
script = ExtResource("1_urx5y")
|
||||||
|
|
||||||
[node name="Shape" type="CollisionShape2D" parent="."]
|
[node name="Shape" type="CollisionShape2D" parent="."]
|
||||||
shape = SubResource("CircleShape2D_61hv0")
|
shape = SubResource("CircleShape2D_61hv0")
|
||||||
debug_color = Color(0.47451, 0, 0.027451, 0.678431)
|
debug_color = Color(1, 0, 0.027451, 0)
|
||||||
|
|
||||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
[connection signal="eaten" from="." to="." method="_on_eaten"]
|
[connection signal="eaten" from="." to="." method="_on_eaten"]
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
[node name="HuntTarget" type="Node2D"]
|
[node name="HuntTarget" type="Node2D"]
|
||||||
script = ExtResource("1_1ex7u")
|
script = ExtResource("1_1ex7u")
|
||||||
tag = null
|
|
||||||
give_up_secs = null
|
give_up_secs = null
|
||||||
|
|
||||||
[node name="Hunter" parent="." instance=ExtResource("2_vjdtc")]
|
[node name="Hunter" parent="." instance=ExtResource("2_vjdtc")]
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
[ext_resource type="Script" path="res://behaviours/hunter.gd" id="1_3bmd5"]
|
[ext_resource type="Script" path="res://behaviours/hunter.gd" id="1_3bmd5"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_kxb8e"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_kxb8e"]
|
||||||
radius = 100.0
|
radius = 8.0
|
||||||
|
|
||||||
[node name="Hunter" type="Node2D"]
|
[node name="Hunter" type="Node2D"]
|
||||||
script = ExtResource("1_3bmd5")
|
script = ExtResource("1_3bmd5")
|
||||||
|
@ -15,7 +15,7 @@ monitorable = false
|
||||||
|
|
||||||
[node name="Shape" type="CollisionShape2D" parent="DetectionArea"]
|
[node name="Shape" type="CollisionShape2D" parent="DetectionArea"]
|
||||||
shape = SubResource("CircleShape2D_kxb8e")
|
shape = SubResource("CircleShape2D_kxb8e")
|
||||||
debug_color = Color(1, 0, 0, 0.419608)
|
debug_color = Color(1, 0, 0, 0.0705882)
|
||||||
|
|
||||||
[connection signal="tracked" from="." to="." method="_on_tracked"]
|
[connection signal="tracked" from="." to="." method="_on_tracked"]
|
||||||
[connection signal="untracked" from="." to="." method="_on_untracked"]
|
[connection signal="untracked" from="." to="." method="_on_untracked"]
|
||||||
|
|
|
@ -4,29 +4,22 @@ class_name Imp
|
||||||
@export var skull_chance: float = 0.2
|
@export var skull_chance: float = 0.2
|
||||||
|
|
||||||
@onready var skull_spawner: Spawner = $"SkullSpawner"
|
@onready var skull_spawner: Spawner = $"SkullSpawner"
|
||||||
|
@onready var sprite: SpriteLeftRight = $"Sprite"
|
||||||
@onready var draggable: Draggable = $"Draggable"
|
@onready var draggable: Draggable = $"Draggable"
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready() -> void:
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
|
func _on_eat_target_eaten(target: Edible):
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
target.queue_free()
|
||||||
func _process(_delta: float) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _on_eat_target_eaten(_target: Edible):
|
|
||||||
if Random.rng.randf() < skull_chance:
|
if Random.rng.randf() < skull_chance:
|
||||||
skull_spawner.spawn()
|
skull_spawner.spawn()
|
||||||
|
|
||||||
|
|
||||||
func _on_draggable_move(movement:Vector2):
|
func _on_draggable_move(movement:Vector2):
|
||||||
if draggable.being_dragged:
|
if draggable.being_dragged:
|
||||||
print("move", movement)
|
|
||||||
move_and_collide(movement)
|
move_and_collide(movement)
|
||||||
|
sprite.handle_move(movement)
|
||||||
|
|
||||||
func _on_move(movement:Vector2):
|
func _on_move(movement:Vector2):
|
||||||
if not draggable.being_dragged:
|
if not draggable.being_dragged:
|
||||||
print("move", movement)
|
|
||||||
move_and_collide(movement)
|
move_and_collide(movement)
|
||||||
|
sprite.handle_move(movement)
|
||||||
|
|
|
@ -1,30 +1,34 @@
|
||||||
[gd_scene load_steps=8 format=3 uid="uid://4d3ksr3171x4"]
|
[gd_scene load_steps=10 format=3 uid="uid://4d3ksr3171x4"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://entities/imp.gd" id="1_dixpc"]
|
[ext_resource type="Script" path="res://entities/imp.gd" id="1_dixpc"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bxbjfev0lhwws" path="res://behaviours/sprite_left_right.tscn" id="2_eqcdi"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_4528r"]
|
[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_4528r"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dfitiajuuvdko" path="res://behaviours/eat_target.tscn" id="3_iybf3"]
|
[ext_resource type="PackedScene" uid="uid://b7bdlh5akhi8s" path="res://behaviours/eat_target.tscn" id="3_iybf3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cyrg770fsetyu" path="res://behaviours/spawner.tscn" id="4_d8lgm"]
|
[ext_resource type="Texture2D" uid="uid://crhwsob76ieya" path="res://entities/imp_left.png" id="3_qda0k"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bubehid53q8h1" path="res://entities/imp_right.png" id="4_0sckn"]
|
||||||
|
[ext_resource type="PackedScene" path="res://behaviours/spawner.tscn" id="4_d8lgm"]
|
||||||
[ext_resource type="PackedScene" uid="uid://uoxwjpmgg27a" path="res://entities/gold.tscn" id="5_yrfoq"]
|
[ext_resource type="PackedScene" uid="uid://uoxwjpmgg27a" path="res://entities/gold.tscn" id="5_yrfoq"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_c5tcn"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_ide4n"]
|
||||||
radius = 16.0
|
radius = 8.0
|
||||||
|
|
||||||
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_08frh"]
|
|
||||||
|
|
||||||
[node name="Imp" type="CharacterBody2D"]
|
[node name="Imp" type="CharacterBody2D"]
|
||||||
collision_layer = 8
|
collision_layer = 8
|
||||||
collision_mask = 14
|
collision_mask = 14
|
||||||
script = ExtResource("1_dixpc")
|
script = ExtResource("1_dixpc")
|
||||||
|
|
||||||
[node name="Shape" type="CollisionShape2D" parent="."]
|
[node name="Sprite" parent="." instance=ExtResource("2_eqcdi")]
|
||||||
shape = SubResource("CircleShape2D_c5tcn")
|
scale = Vector2(2, 2)
|
||||||
|
texture = ExtResource("3_qda0k")
|
||||||
|
left_texture = ExtResource("3_qda0k")
|
||||||
|
right_texture = ExtResource("4_0sckn")
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="."]
|
[node name="Shape" type="CollisionShape2D" parent="."]
|
||||||
scale = Vector2(32, 32)
|
scale = Vector2(4, 4)
|
||||||
texture = SubResource("PlaceholderTexture2D_08frh")
|
shape = SubResource("CircleShape2D_ide4n")
|
||||||
|
|
||||||
[node name="Draggable" parent="." instance=ExtResource("3_4528r")]
|
[node name="Draggable" parent="." instance=ExtResource("3_4528r")]
|
||||||
scale = Vector2(2, 2)
|
scale = Vector2(4, 4)
|
||||||
|
|
||||||
[node name="DragSound" type="AudioStreamPlayer2D" parent="Draggable"]
|
[node name="DragSound" type="AudioStreamPlayer2D" parent="Draggable"]
|
||||||
scale = Vector2(0.5, 0.5)
|
scale = Vector2(0.5, 0.5)
|
||||||
|
@ -33,6 +37,7 @@ scale = Vector2(0.5, 0.5)
|
||||||
scale = Vector2(0.5, 0.5)
|
scale = Vector2(0.5, 0.5)
|
||||||
|
|
||||||
[node name="EatTarget" parent="." instance=ExtResource("3_iybf3")]
|
[node name="EatTarget" parent="." instance=ExtResource("3_iybf3")]
|
||||||
|
scale = Vector2(2, 2)
|
||||||
tag = &"Sheep"
|
tag = &"Sheep"
|
||||||
|
|
||||||
[node name="SkullSpawner" parent="." instance=ExtResource("4_d8lgm")]
|
[node name="SkullSpawner" parent="." instance=ExtResource("4_d8lgm")]
|
||||||
|
|
BIN
entities/imp_left.png
(Stored with Git LFS)
Normal file
BIN
entities/imp_left.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
entities/imp_left.png.import
Normal file
34
entities/imp_left.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://crhwsob76ieya"
|
||||||
|
path="res://.godot/imported/imp_left.png-08c29cf2ea70a06668881e6734bc6acb.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://entities/imp_left.png"
|
||||||
|
dest_files=["res://.godot/imported/imp_left.png-08c29cf2ea70a06668881e6734bc6acb.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
BIN
entities/imp_right.png
(Stored with Git LFS)
Normal file
BIN
entities/imp_right.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
entities/imp_right.png.import
Normal file
34
entities/imp_right.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bubehid53q8h1"
|
||||||
|
path="res://.godot/imported/imp_right.png-5420c8b334729ea80ccdda0be5b78434.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://entities/imp_right.png"
|
||||||
|
dest_files=["res://.godot/imported/imp_right.png-5420c8b334729ea80ccdda0be5b78434.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
Loading…
Reference in a new issue