From fd91909d0475c68aa25e41212693f0444ea6605a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 03:46:21 +0200 Subject: [PATCH] Setup a nice little scene --- entities/imp.tscn | 11 +++++++---- scenes/game/main_game.tscn | 21 ++++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/entities/imp.tscn b/entities/imp.tscn index a083533..ee9d5a7 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -42,9 +42,11 @@ shape = SubResource("CircleShape2D_ide4n") [node name="CoinSpawner" parent="." instance=ExtResource("4_d8lgm")] scene = ExtResource("5_yrfoq") -[node name="Timer" type="Timer" parent="CoinSpawner"] -wait_time = 0.8 -autostart = true +[node name="TimerStddev" parent="CoinSpawner" instance=ExtResource("10_phvea")] +mean_secs = 5.0 +deviation = 4.0 +min_secs = 1.0 +max_secs = 9.0 [node name="MovementSampler" parent="." node_paths=PackedStringArray("possibilities") instance=ExtResource("7_ech8d")] possibilities = [NodePath("../MovementWander/WanderPriority"), NodePath("../MovementHunt/HuntPriority")] @@ -89,7 +91,7 @@ acceptable_diets = Array[StringName]([&"Meat"]) shape = SubResource("CircleShape2D_qhk1q") debug_color = Color(1, 0, 0, 0) -[connection signal="timeout" from="CoinSpawner/Timer" to="CoinSpawner" method="spawn"] +[connection signal="timeout" from="CoinSpawner/TimerStddev" to="CoinSpawner" method="spawn"] [connection signal="ready" from="MovementSampler" to="MovementSampler" method="enable"] [connection signal="changed_direction" from="MovementWander" to="MovementWander/WanderPriority" method="priority_conditional"] [connection signal="move" from="MovementWander" to="." method="_on_move"] @@ -101,4 +103,5 @@ debug_color = Color(1, 0, 0, 0) [connection signal="tracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null" unbinds=1] [connection signal="untracked" from="MovementHunt/TrackerMeat" to="MovementHunt/TrackerMeat/TargetPicker" method="clear_if_target"] [connection signal="target_changed" from="MovementHunt/TrackerMeat/TargetPicker" to="MovementHunt" method="set_target" unbinds=1] +[connection signal="target_changed" from="MovementHunt/TrackerMeat/TargetPicker" to="MovementHunt/TrackerMeat/TargetPicker" method="sample_target_if_null" unbinds=2] [connection signal="eaten" from="Eater" to="." method="_on_eater_eaten"] diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index f8af012..5a407d8 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://cxj5aud02f40j"] +[gd_scene load_steps=13 format=3 uid="uid://cxj5aud02f40j"] [ext_resource type="Script" path="res://scenes/game/main_game.gd" id="1_wiglu"] [ext_resource type="PackedScene" uid="uid://dm068vaseh45n" path="res://scenes/game/game_camera.tscn" id="2_db5xs"] @@ -7,6 +7,8 @@ [ext_resource type="PackedScene" uid="uid://col1q3elvkfwk" path="res://scenes/game/cursor.tscn" id="5_g504x"] [ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="6_j2kdp"] [ext_resource type="PackedScene" uid="uid://4d3ksr3171x4" path="res://entities/imp.tscn" id="7_7od2n"] +[ext_resource type="PackedScene" uid="uid://tx1qi6ahlxjp" path="res://behaviours/spawner.tscn" id="7_kqc55"] +[ext_resource type="PackedScene" uid="uid://g8t6dt0ye6n3" path="res://behaviours/timer_stddev.tscn" id="9_8875b"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_058kb"] texture = ExtResource("2_o7bg5") @@ -831,11 +833,8 @@ unique_name_in_owner = true [node name="Cursor" parent="." instance=ExtResource("5_g504x")] -[node name="Sheep" parent="." instance=ExtResource("6_j2kdp")] -position = Vector2(-246, 25) - [node name="Imp" parent="." instance=ExtResource("7_7od2n")] -position = Vector2(237, 10) +position = Vector2(102, -21) [node name="Walls" type="Node2D" parent="."] @@ -873,3 +872,15 @@ collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Walls/LeftBoundary"] shape = SubResource("WorldBoundaryShape2D_htttx") + +[node name="Spawner" parent="." instance=ExtResource("7_kqc55")] +position = Vector2(-386, 162) +scene = ExtResource("6_j2kdp") + +[node name="TimerStddev" parent="Spawner" instance=ExtResource("9_8875b")] +autostart = true +mean_secs = 6.0 +min_secs = 3.0 +max_secs = 9.0 + +[connection signal="timeout" from="Spawner/TimerStddev" to="Spawner" method="spawn"]