Skip to content

Commit 7dbcc23

Browse files
Added blood particles and clothes scraps hud
1 parent 9783dcd commit 7dbcc23

File tree

5 files changed

+90
-22
lines changed

5 files changed

+90
-22
lines changed

Game.tscn

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=19 format=2]
1+
[gd_scene load_steps=21 format=2]
22

33
[ext_resource path="res://Player.tscn" type="PackedScene" id=1]
44
[ext_resource path="res://EditorTileset.tres" type="TileSet" id=2]
@@ -9,6 +9,7 @@
99
[ext_resource path="res://Minimap.gd" type="Script" id=7]
1010
[ext_resource path="res://Sprites/Spells/Empty.png" type="Texture" id=8]
1111
[ext_resource path="res://WandRenderRect.tscn" type="PackedScene" id=9]
12+
[ext_resource path="res://Sprites/Items/Scraps.png" type="Texture" id=10]
1213

1314
[sub_resource type="StyleBoxFlat" id=1]
1415
content_margin_top = 3.0
@@ -26,7 +27,10 @@ corner_radius_bottom_left = 2
2627
size = 12
2728
font_data = ExtResource( 5 )
2829

29-
[sub_resource type="StyleBoxFlat" id=3]
30+
[sub_resource type="DynamicFont" id=3]
31+
font_data = ExtResource( 5 )
32+
33+
[sub_resource type="StyleBoxFlat" id=4]
3034
content_margin_left = 5.0
3135
content_margin_right = 5.0
3236
content_margin_top = 5.0
@@ -41,17 +45,17 @@ corner_radius_bottom_right = 10
4145
corner_radius_bottom_left = 5
4246
anti_aliasing = false
4347

44-
[sub_resource type="DynamicFont" id=4]
48+
[sub_resource type="DynamicFont" id=5]
4549
size = 12
4650
use_mipmaps = true
4751
font_data = ExtResource( 5 )
4852

49-
[sub_resource type="DynamicFont" id=5]
53+
[sub_resource type="DynamicFont" id=6]
5054
size = 10
5155
use_mipmaps = true
5256
font_data = ExtResource( 5 )
5357

54-
[sub_resource type="StyleBoxFlat" id=6]
58+
[sub_resource type="StyleBoxFlat" id=7]
5559
content_margin_left = 5.0
5660
content_margin_right = 5.0
5761
content_margin_top = 5.0
@@ -66,14 +70,14 @@ corner_radius_bottom_right = 5
6670
corner_radius_bottom_left = 2
6771
anti_aliasing = false
6872

69-
[sub_resource type="StyleBoxFlat" id=7]
73+
[sub_resource type="StyleBoxFlat" id=8]
7074
bg_color = Color( 0, 0, 0, 1 )
7175

72-
[sub_resource type="DynamicFont" id=8]
76+
[sub_resource type="DynamicFont" id=9]
7377
use_mipmaps = true
7478
font_data = ExtResource( 5 )
7579

76-
[sub_resource type="DynamicFont" id=9]
80+
[sub_resource type="DynamicFont" id=10]
7781
size = 11
7882
use_mipmaps = true
7983
font_data = ExtResource( 5 )
@@ -288,13 +292,36 @@ visible = false
288292
margin_top = -16.0
289293
margin_bottom = -225.0
290294

295+
[node name="Scraps" type="TextureRect" parent="HUD/HUD"]
296+
anchor_top = 1.0
297+
anchor_bottom = 1.0
298+
margin_left = 2.0
299+
margin_top = -19.0
300+
margin_right = 18.0
301+
margin_bottom = -3.0
302+
texture = ExtResource( 10 )
303+
__meta__ = {
304+
"_edit_use_anchors_": false
305+
}
306+
307+
[node name="Amount" type="Label" parent="HUD/HUD/Scraps"]
308+
margin_left = 19.0
309+
margin_top = 1.0
310+
margin_right = 53.0
311+
margin_bottom = 17.0
312+
custom_fonts/font = SubResource( 3 )
313+
text = "2"
314+
__meta__ = {
315+
"_edit_use_anchors_": false
316+
}
317+
291318
[node name="Description" type="Panel" parent="HUD/HUD"]
292319
margin_left = 40.0
293320
margin_top = 40.0
294321
margin_right = 184.0
295322
margin_bottom = 104.0
296323
size_flags_horizontal = 5
297-
custom_styles/panel = SubResource( 3 )
324+
custom_styles/panel = SubResource( 4 )
298325
__meta__ = {
299326
"_edit_use_anchors_": false
300327
}
@@ -305,7 +332,7 @@ margin_top = 8.0
305332
margin_right = 136.0
306333
margin_bottom = 20.0
307334
size_flags_horizontal = 5
308-
custom_fonts/font = SubResource( 4 )
335+
custom_fonts/font = SubResource( 5 )
309336
text = "Name"
310337
autowrap = true
311338

@@ -315,7 +342,7 @@ margin_top = 18.0
315342
margin_right = 136.0
316343
margin_bottom = 30.0
317344
size_flags_horizontal = 5
318-
custom_fonts/font = SubResource( 5 )
345+
custom_fonts/font = SubResource( 6 )
319346
text = "Information"
320347
autowrap = true
321348
__meta__ = {
@@ -328,8 +355,8 @@ margin_top = 40.0
328355
margin_right = 71.0
329356
margin_bottom = 59.0
330357
size_flags_horizontal = 5
331-
custom_styles/normal = SubResource( 6 )
332-
custom_fonts/font = SubResource( 4 )
358+
custom_styles/normal = SubResource( 7 )
359+
custom_fonts/font = SubResource( 5 )
333360
text = "Name"
334361
__meta__ = {
335362
"_edit_use_anchors_": false
@@ -339,7 +366,7 @@ __meta__ = {
339366
modulate = Color( 1, 1, 1, 0 )
340367
anchor_right = 1.0
341368
anchor_bottom = 1.0
342-
custom_styles/panel = SubResource( 7 )
369+
custom_styles/panel = SubResource( 8 )
343370
__meta__ = {
344371
"_edit_use_anchors_": false
345372
}
@@ -353,7 +380,7 @@ margin_left = -56.0
353380
margin_top = -158.0
354381
margin_right = 56.0
355382
margin_bottom = -142.0
356-
custom_fonts/font = SubResource( 8 )
383+
custom_fonts/font = SubResource( 9 )
357384
text = "You Are Dead"
358385
align = 1
359386
__meta__ = {
@@ -369,7 +396,7 @@ margin_left = -132.0
369396
margin_top = -48.0
370397
margin_right = 132.0
371398
margin_bottom = 48.0
372-
custom_fonts/font = SubResource( 9 )
399+
custom_fonts/font = SubResource( 10 )
373400
text = "Cause of Death:
374401
Run Length:
375402
@@ -384,7 +411,7 @@ __meta__ = {
384411
[node name="Generating" type="Panel" parent="HUD/HUD"]
385412
anchor_right = 1.0
386413
anchor_bottom = 1.0
387-
custom_styles/panel = SubResource( 7 )
414+
custom_styles/panel = SubResource( 8 )
388415
__meta__ = {
389416
"_edit_use_anchors_": false
390417
}
@@ -398,7 +425,7 @@ margin_left = -56.0
398425
margin_top = -30.0
399426
margin_right = 56.0
400427
margin_bottom = -14.0
401-
custom_fonts/font = SubResource( 8 )
428+
custom_fonts/font = SubResource( 9 )
402429
text = "Generating World"
403430
align = 1
404431
__meta__ = {
@@ -414,7 +441,7 @@ margin_left = -132.0
414441
margin_top = -48.0
415442
margin_right = 132.0
416443
margin_bottom = 48.0
417-
custom_fonts/font = SubResource( 9 )
444+
custom_fonts/font = SubResource( 10 )
418445
text = "Avoid breaking your knees by not falling long distances"
419446
align = 1
420447
valign = 1
@@ -450,5 +477,5 @@ drag_margin_top = 0.4
450477
drag_margin_bottom = 0.4
451478

452479
[connection signal="player_died" from="Player" to="HUD" method="_on_player_died"]
453-
[connection signal="generated_world" from="World" to="Player" method="_on_generated_world"]
454480
[connection signal="generated_world" from="World" to="HUD" method="_on_generated_world"]
481+
[connection signal="generated_world" from="World" to="Player" method="_on_generated_world"]

HUD.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var advice := [
2020
"If you get lost, try to remember where you are",
2121
"If an enemy attacks you, dodge",
2222
"Use the controls to maneuver your character",
23+
"If you find yourself surrounded by enemies, get out of there",
2324
]
2425
var player_died := false
2526
func _ready():
@@ -48,6 +49,7 @@ func _process(delta):
4849
else:
4950
$HUD/Messages.visible = false
5051

52+
$HUD/Scraps/Amount.text = str(Items.cloth_scraps)
5153
for i in $HUD/Wands.get_child_count():
5254
$HUD/Wands.get_child(i).render_wand(Items.player_wands[i], i == Items.selected_wand)
5355

Particles/Blood.gd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extends RigidBody2D
2+
3+
var timer := 0.0
4+
5+
func _physics_process(delta):
6+
timer += delta
7+
if modulate.a <= 0.0:
8+
queue_free()
9+
if timer > 0.5:
10+
modulate.a -= 0.05
11+
$Polygon2D.rotation = linear_velocity.angle()

Particles/Blood.tscn

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[gd_scene load_steps=2 format=2]
2+
3+
[ext_resource path="res://Particles/Blood.gd" type="Script" id=1]
4+
5+
[node name="Blood" type="RigidBody2D"]
6+
collision_layer = 0
7+
collision_mask = 6
8+
gravity_scale = 5.0
9+
script = ExtResource( 1 )
10+
11+
[node name="Polygon2D" type="Polygon2D" parent="."]
12+
polygon = PoolVector2Array( 0, -3, -1, 0, 0, 1, 1, 0 )
13+
14+
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
15+
polygon = PoolVector2Array( 0, -3, -1, 0, 0, 1, 1, 0 )

Player.gd

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,26 @@ func _ready():
5151

5252
func _process(delta):
5353
if health.poked_holes > 0:
54-
if Input.is_action_just_pressed("seal_blood"):
54+
for i in health.poked_holes:
55+
if randf()>0.9:
56+
var n :RigidBody2D = preload("res://Particles/Blood.tscn").instance()
57+
n.position = position + Vector2(0, 6)
58+
n.linear_velocity = Vector2(-200 + randf()*400, -80 + randf()*120)
59+
if not blood_is_gasoline:
60+
n.modulate = ColorN("red")
61+
else:
62+
n.modulate = ColorN("green")
63+
get_parent().add_child(n)
64+
if Input.is_action_just_pressed("seal_blood") and Items.cloth_scraps > 0:
65+
Items.cloth_scraps -= 1
5566
if randf()<0.92:
5667
health.poked_holes -= 1
5768
if health.poked_holes < 0:
5869
health.poked_holes = 0
5970
if health.poked_holes == 0:
6071
message_send("Wound has been covered, bleeding has stopped")
6172

62-
if randf() < 0.002:
73+
if randf() < 0.0005:
6374
health.poked_holes -= 1
6475
if health.poked_holes < 0:
6576
health.poked_holes = 0
@@ -428,6 +439,8 @@ func move_damp(delta):
428439
speed.x += WALK_ACCEL
429440
haxis = 1.0
430441
health.temperature += 0.002
442+
else:
443+
health.temperature = move_toward(health.temperature, 30, 0.01)
431444
health.temperature = move_toward(health.temperature, 30, 0.001)
432445
if abs(haxis)<0.5:
433446
speed.x *= pow(0.8, delta*60)

0 commit comments

Comments
 (0)