From ca55f6753f49f9a3ccc4427d395a1c257d4c6359 Mon Sep 17 00:00:00 2001 From: Aino Spring Date: Tue, 19 Nov 2024 15:55:34 +0100 Subject: [PATCH] #15 fixed --- fish.gd | 13 ++++++++----- main.tscn | 6 +++--- project.godot | 4 ++-- shop.gd | 3 --- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fish.gd b/fish.gd index 06e1a06..7b1e8b0 100644 --- a/fish.gd +++ b/fish.gd @@ -63,7 +63,7 @@ func _process(delta): SWIM: swim, FOOD: food }[state].call() - + hunger = hunger + delta * hungerSpeed if (hunger > hungerThreshold): hunger = hungerThreshold @@ -76,6 +76,9 @@ func _process(delta): sprite.scale.x = 1 mouth.scale.x = 1 +func is_hungry(): + return hunger > hungerThreshold / 2 + func idle(): boredom = boredom + rng.randi_range(0,5) if (boredom > boredomThreshold): @@ -84,13 +87,13 @@ func idle(): updateOutline() func swim(): - if (hunger>hungerThreshold/2 && FoodGroup.get_children().size() > 0): + if (is_hungry() && FoodGroup.get_children().size() > 0): state = FOOD return food() if (tired == 0): direction = Vector2(rng.randi_range(-1,1), rng.randi_range(-1,1)) - if (hunger > hungerThreshold/2): speed = maxSpeed / 5 + if (is_hungry()): speed = maxSpeed / 5 else: speed = maxSpeed apply_impulse(Vector2(direction.x/100*speed,direction.y/500*speed), Vector2(0.5,0.5)) @@ -99,7 +102,7 @@ func swim(): if (tired > tiredThreshold): state = IDLE tired = 0 - if (hunger > hungerThreshold/2): tired = tiredThreshold/2 + if (is_hungry()): tired = tiredThreshold/2 moneyDrop() @@ -115,7 +118,7 @@ func moneyDrop(): func food(): var current_foods = FoodGroup.get_children() - if current_foods.size() == 0: + if current_foods.size() == 0 || !is_hungry(): state = SWIM return swim() var closest_distance = 9999 diff --git a/main.tscn b/main.tscn index 3f72941..1175d25 100644 --- a/main.tscn +++ b/main.tscn @@ -101,12 +101,12 @@ Label/fonts/font = ExtResource("16_txocg") [sub_resource type="RectangleShape2D" id="RectangleShape2D_4ss04"] size = Vector2(96, 57) -[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1ihl1"] - [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_gf4ul"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_akpou"] +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1ihl1"] + [node name="Node2D" type="Node2D"] script = ExtResource("1_rauu0") metadata/_edit_vertical_guides_ = [-82.0, 560.0, -76.0, -12.0] @@ -510,9 +510,9 @@ theme = ExtResource("8_pmiyt") theme_override_colors/font_color = Color(0.286275, 0.333333, 0.533333, 1) theme_override_fonts/font = ExtResource("15_fg7uf") theme_override_font_sizes/font_size = 8 -theme_override_styles/normal = SubResource("StyleBoxEmpty_1ihl1") theme_override_styles/focus = SubResource("StyleBoxEmpty_gf4ul") theme_override_styles/read_only = SubResource("StyleBoxEmpty_akpou") +theme_override_styles/normal = SubResource("StyleBoxEmpty_1ihl1") text = "FISH NAME" alignment = 1 max_length = 10 diff --git a/project.godot b/project.godot index ac75ae9..d2fdffe 100644 --- a/project.godot +++ b/project.godot @@ -14,7 +14,7 @@ config/name="Lospequarium" config/version="6" config/tags=PackedStringArray("lospec_collab", "real_game") run/main_scene="res://main.tscn" -config/features=PackedStringArray("4.2", "GL Compatibility") +config/features=PackedStringArray("4.3", "GL Compatibility") config/icon="res://art/icons/icon.png" [display] @@ -47,7 +47,7 @@ folder_colors={ ChangeFish={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } diff --git a/shop.gd b/shop.gd index fbb6ddb..c00cc31 100644 --- a/shop.gd +++ b/shop.gd @@ -172,6 +172,3 @@ func checkIfClickedShopButtonIsDisable (event, button): if (event is InputEventMouseButton && event.pressed && event.button_index==1): if (button.disabled): get_node("/root/Node2D/Sound/CantBuy").playing = true - - -