Skip to content

Commit

Permalink
Update rats and hunger bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon32 committed Aug 19, 2024
1 parent 40e5001 commit 321e28b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 39 deletions.
45 changes: 10 additions & 35 deletions Characters/Rat/EnemyRat.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ diffuse_texture = ExtResource("2_n6qgb")

[sub_resource type="Animation" id="Animation_3layy"]
resource_name = "Idle"
length = 1.5
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
Expand Down Expand Up @@ -41,38 +42,9 @@ tracks/0/keys = {
"values": [7]
}

[sub_resource type="Animation" id="Animation_eol3v"]
resource_name = "is_eaten_from_left"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 1,
"values": [10, 11, 12, 13, 19]
}

[sub_resource type="Animation" id="Animation_lbinx"]
resource_name = "is_eaten_from_right"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 1,
"values": [15, 16, 17, 18, 19]
}

[sub_resource type="Animation" id="Animation_wpmag"]
resource_name = "walk"
length = 0.8
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
Expand All @@ -81,18 +53,16 @@ tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.133333, 0.466667, 0.566667),
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [5, 6, 7, 8]
"values": [4, 5, 6, 7]
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_m6iju"]
_data = {
"Idle": SubResource("Animation_3layy"),
"RESET": SubResource("Animation_034ji"),
"is_eaten_from_left": SubResource("Animation_eol3v"),
"is_eaten_from_right": SubResource("Animation_lbinx"),
"walk": SubResource("Animation_wpmag")
}

Expand Down Expand Up @@ -130,13 +100,18 @@ advance_mode = 2

[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_swycp"]

[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_cu110"]

[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_tdq3t"]

[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_n6kqg"]
states/End/position = Vector2(570, 133)
states/Start/position = Vector2(64, 133)
states/idle/node = SubResource("AnimationNodeBlendTree_jildm")
states/idle/position = Vector2(328, 49)
states/run/node = SubResource("AnimationNodeBlendTree_u8vwk")
states/run/position = Vector2(328, 261)
transitions = ["Start", "idle", SubResource("AnimationNodeStateMachineTransition_on6sh"), "idle", "run", SubResource("AnimationNodeStateMachineTransition_75hwq"), "run", "idle", SubResource("AnimationNodeStateMachineTransition_swycp")]
transitions = ["Start", "idle", SubResource("AnimationNodeStateMachineTransition_on6sh"), "idle", "run", SubResource("AnimationNodeStateMachineTransition_75hwq"), "run", "idle", SubResource("AnimationNodeStateMachineTransition_swycp"), "idle", "End", SubResource("AnimationNodeStateMachineTransition_cu110"), "run", "End", SubResource("AnimationNodeStateMachineTransition_tdq3t")]
graph_offset = Vector2(-41, 3)

[node name="EnemyRat" type="CharacterBody2D" groups=["Enemy"]]
Expand Down
5 changes: 5 additions & 0 deletions Levels/level_01/Level_01.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -1564,3 +1564,8 @@ target = NodePath("../hero")
[node name="EnemyRat3" parent="." node_paths=PackedStringArray("target") instance=ExtResource("17_lavig")]
position = Vector2(275, 209)
target = NodePath("../hero")

[node name="Out of bounds" type="StaticBody2D" parent="."]

[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Out of bounds"]
polygon = PackedVector2Array(529, -46, 786, -184, 793, 739, -245, 747, -251, -174, 787, -184, 786, -184, 529, -46, -17, -49, -16, 592, 529, 593)
5 changes: 5 additions & 0 deletions Levels/level_02/Level_02.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -1576,3 +1576,8 @@ position = Vector2(313, 52)
scale = Vector2(1.5, 1.5)
slime_size = 400
target = NodePath("../hero")

[node name="Out of bounds" type="StaticBody2D" parent="."]

[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Out of bounds"]
polygon = PackedVector2Array(529, -46, 786, -184, 793, 739, -245, 747, -251, -174, 787, -184, 786, -184, 529, -46, -17, -49, -16, 592, 529, 593)
8 changes: 4 additions & 4 deletions UI/UI.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ grow_horizontal = 0
layout_mode = 2
text = "Hunger"

[node name="ProgressBar" type="ProgressBar" parent="Control/HBoxContainer"]
modulate = Color(0.12549, 1, 0.247059, 1)
[node name="HungerBar" type="ProgressBar" parent="Control/HBoxContainer"]
modulate = Color(1, 0.172549, 0.247059, 1)
custom_minimum_size = Vector2(150, 25)
layout_mode = 2
size_flags_vertical = 4
min_value = 100.0
max_value = 400.0
min_value = 95.0
max_value = 800.0
value = 100.0
show_percentage = false
script = ExtResource("1_0ykeg")
Expand Down
9 changes: 9 additions & 0 deletions UI/progress_bar.gd
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
extends ProgressBar

# Get a local copy of your fill StyleBoxFlat
@onready var progress_style : StyleBoxFlat = get_theme_stylebox("fill").duplicate()

func size_changed(size : int):
value = size
var percent = (value - min_value) / (max_value - min_value)
modulate = Color.RED.lerp(Color.GREEN, percent)

GlobalSignals.debug.emit("Hunger percent", str(percent) + str(modulate))

# Called when the node enters the scene tree for the first time.
func _ready():
var percent = (value - min_value) / (max_value - min_value)
modulate = Color.RED.lerp(Color.GREEN, percent)
GlobalSignals.hero_size.connect(size_changed)


Expand Down

0 comments on commit 321e28b

Please sign in to comment.