Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
outfrost committed Apr 26, 2021
2 parents 0da3aaf + daa2b73 commit d055ecd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 25 deletions.
20 changes: 18 additions & 2 deletions character/PlayerCharacter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export var walk_sound_interval: float = 0.5
export var swing_sounds: Array
export var hit_sounds: Array

var heart_full = preload("res://character/Heart_Full.tres")
var heart_half = preload("res://character/Heart_Half.tres")
var heart_empty = preload("res://character/Heart_Empty.tres")

onready var sprite: AnimatedSprite = $AnimatedSprite

var inventory: Dictionary = {}
Expand Down Expand Up @@ -40,7 +44,7 @@ func _physics_process(delta: float) -> void:
Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
).clamped(1.0)
var moving: bool = !direction.is_equal_approx(Vector2.ZERO)

if moving:
last_movement_dir = direction.normalized()
if walk_sound_timer > walk_sound_interval:
Expand All @@ -50,7 +54,9 @@ func _physics_process(delta: float) -> void:
else:
walk_sound_timer = 0.0
move_and_slide(direction * run_speed)


_update_health_display()

if playing_action:
return
var angle = direction.angle() if moving else last_movement_dir.angle()
Expand Down Expand Up @@ -182,3 +188,13 @@ func print_inventory():

func _process(delta):
DebugLabel.display(self, self.health)

func _update_health_display():
for heart in range($CanvasLayer.get_child_count()):
if health > heart * 20.0 + 10:
$CanvasLayer.get_child(heart).texture = heart_full
elif health > heart * 20.0:

$CanvasLayer.get_child(heart).texture = heart_half
else:
$CanvasLayer.get_child(heart).texture = heart_empty
45 changes: 25 additions & 20 deletions character/PlayerCharacter.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -132,46 +132,51 @@ bus = "Effects"
[node name="CanvasLayer" type="CanvasLayer" parent="."]

[node name="TextureRect" type="TextureRect" parent="CanvasLayer"]
margin_left = 16.0
margin_top = 16.0
margin_right = 48.0
margin_bottom = 48.0
margin_left = 80.0
margin_top = 592.0
margin_right = 144.0
margin_bottom = 656.0
expand = true
__meta__ = {
"_edit_use_anchors_": false
}

[node name="TextureRect2" type="TextureRect" parent="CanvasLayer"]
margin_left = 48.0
margin_top = 16.0
margin_right = 80.0
margin_bottom = 48.0
margin_left = 144.0
margin_top = 592.0
margin_right = 208.0
margin_bottom = 656.0
expand = true
__meta__ = {
"_edit_use_anchors_": false
}

[node name="TextureRect3" type="TextureRect" parent="CanvasLayer"]
margin_left = 80.0
margin_top = 16.0
margin_right = 112.0
margin_bottom = 48.0
margin_left = 208.0
margin_top = 592.0
margin_right = 272.0
margin_bottom = 656.0
expand = true
__meta__ = {
"_edit_use_anchors_": false
}

[node name="TextureRect4" type="TextureRect" parent="CanvasLayer"]
margin_left = 112.0
margin_top = 16.0
margin_right = 144.0
margin_bottom = 48.0
margin_left = 272.0
margin_top = 592.0
margin_right = 336.0
margin_bottom = 656.0
expand = true
__meta__ = {
"_edit_use_anchors_": false
}

[node name="TextureRect5" type="TextureRect" parent="CanvasLayer"]
margin_left = 144.0
margin_top = 16.0
margin_right = 176.0
margin_bottom = 48.0
margin_left = 336.0
margin_top = 592.0
margin_right = 400.0
margin_bottom = 656.0
expand = true
__meta__ = {
"_edit_use_anchors_": false
}
6 changes: 3 additions & 3 deletions level/Level0.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ extents = Vector2( 160, 96 )
extents = Vector2( 128, 128 )

[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 320, 224 )
extents = Vector2( 288, 160 )

[sub_resource type="RectangleShape2D" id=6]
extents = Vector2( 288, 160 )
extents = Vector2( 320, 224 )

[sub_resource type="CapsuleShape2D" id=7]
radius = 192.0
Expand Down Expand Up @@ -121,7 +121,7 @@ position = Vector2( 336, -1424 )
position = Vector2( 272, -1296 )

[node name="StaticBody2D82" parent="YSort" instance=ExtResource( 2 )]
position = Vector2( 112, -1296 )
position = Vector2( 80, -1296 )

[node name="StaticBody2D83" parent="YSort" instance=ExtResource( 2 )]
position = Vector2( -80, -1392 )
Expand Down

0 comments on commit d055ecd

Please sign in to comment.