diff --git a/ActionRPG-HeartBeast/Enemies/Bat.gd b/ActionRPG-HeartBeast/Enemies/Bat.gd
index e1e990d..99cb303 100644
--- a/ActionRPG-HeartBeast/Enemies/Bat.gd
+++ b/ActionRPG-HeartBeast/Enemies/Bat.gd
@@ -20,6 +20,7 @@ var state = IDLE
onready var sprite = $AnimatedSprite
onready var stats = $Stats
onready var playerDetectionZone = $PlayerDetectionZone
+onready var hurtbox = $Hurtbox
func _physics_process(delta):
knockback = knockback.move_toward(Vector2.ZERO, 200 * delta)
@@ -51,6 +52,7 @@ func seek_player():
func _on_Hurtbox_area_entered(area):
stats.health -= area.damage
knockback = area.knockback_vector * 120
+ hurtbox.create_hit_effect()
#queue_free() # Replace with function body.
func _on_Stats_no_health():
diff --git a/ActionRPG-HeartBeast/Enemies/Bat.tscn b/ActionRPG-HeartBeast/Enemies/Bat.tscn
index aa49ee9..982fc58 100644
--- a/ActionRPG-HeartBeast/Enemies/Bat.tscn
+++ b/ActionRPG-HeartBeast/Enemies/Bat.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=16 format=2]
+[gd_scene load_steps=18 format=2]
[ext_resource path="res://Enemies/Bat.png" type="Texture" id=1]
[ext_resource path="res://Shadows/SmallShadow.png" type="Texture" id=2]
@@ -6,6 +6,7 @@
[ext_resource path="res://Enemies/Bat.gd" type="Script" id=4]
[ext_resource path="res://Stats.tscn" type="PackedScene" id=5]
[ext_resource path="res://Enemies/PlayerDetectionZone.tscn" type="PackedScene" id=6]
+[ext_resource path="res://Overlap/Hitbox.tscn" type="PackedScene" id=7]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
@@ -45,6 +46,9 @@ height = 6.0
[sub_resource type="CircleShape2D" id=9]
radius = 61.0328
+[sub_resource type="CircleShape2D" id=10]
+radius = 5.0
+
[node name="Bat" type="KinematicBody2D"]
collision_layer = 16
script = ExtResource( 4 )
@@ -78,8 +82,16 @@ max_health = 2
modulate = Color( 1, 1, 1, 0.258824 )
shape = SubResource( 9 )
+[node name="Hitbox" parent="." instance=ExtResource( 7 )]
+collision_mask = 4
+
+[node name="CollisionShape2D" parent="Hitbox" index="0"]
+position = Vector2( 0, -15 )
+shape = SubResource( 10 )
+
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="no_health" from="Stats" to="." method="_on_Stats_no_health"]
[editable path="Hurtbox"]
[editable path="PlayerDetectionZone"]
+[editable path="Hitbox"]
diff --git a/ActionRPG-HeartBeast/Overlap/Hurtbox.gd b/ActionRPG-HeartBeast/Overlap/Hurtbox.gd
index 1c8fa82..35c74df 100644
--- a/ActionRPG-HeartBeast/Overlap/Hurtbox.gd
+++ b/ActionRPG-HeartBeast/Overlap/Hurtbox.gd
@@ -1,22 +1,36 @@
extends Area2D
-export(bool) var show_hit = true
-
const HitEffect = preload("res://Effects/HitEffect.tscn")
-# Called when the node enters the scene tree for the first time.
-func _ready():
- pass # Replace with function body.
+var invincible = false setget set_invincible
+onready var timer = $Timer
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-#func _process(delta):
-# pass
+signal invincibility_started
+signal invincibility_ended
+func set_invincible(value):
+ invincible = value
+ if invincible == true:
+ emit_signal("invincibility_started")
+ else:
+ emit_signal("invincibility_ended")
-func _on_Hurtbox_area_entered(area):
- if show_hit:
- var effect = HitEffect.instance()
- var main = get_tree().current_scene
- main.add_child(effect)
- effect.global_position = global_position
+func start_invincibility(duration):
+ self.invincible = true
+ timer.start(duration)
+
+func create_hit_effect():
+ var effect = HitEffect.instance()
+ var main = get_tree().current_scene
+ main.add_child(effect)
+ effect.global_position = global_position
+
+func _on_Timer_timeout():
+ self.invincible = false
+
+func _on_Hurtbox_invincibility_ended():
+ monitorable = true
+
+func _on_Hurtbox_invincibility_started():
+ set_deferred("monitorable", false)
diff --git a/ActionRPG-HeartBeast/Overlap/Hurtbox.tscn b/ActionRPG-HeartBeast/Overlap/Hurtbox.tscn
index 2f1ccee..b0c064f 100644
--- a/ActionRPG-HeartBeast/Overlap/Hurtbox.tscn
+++ b/ActionRPG-HeartBeast/Overlap/Hurtbox.tscn
@@ -9,4 +9,8 @@ script = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
-[connection signal="area_entered" from="." to="." method="_on_Hurtbox_area_entered"]
+[node name="Timer" type="Timer" parent="."]
+
+[connection signal="invincibility_ended" from="." to="." method="_on_Hurtbox_invincibility_ended"]
+[connection signal="invincibility_started" from="." to="." method="_on_Hurtbox_invincibility_started"]
+[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
diff --git a/ActionRPG-HeartBeast/Player/Player.gd b/ActionRPG-HeartBeast/Player/Player.gd
index f04fd6e..48febd1 100644
--- a/ActionRPG-HeartBeast/Player/Player.gd
+++ b/ActionRPG-HeartBeast/Player/Player.gd
@@ -3,6 +3,7 @@ extends KinematicBody2D
var velocity = Vector2.ZERO
var input_vector = Vector2.ZERO
var roll_vector = Vector2.DOWN
+var stats = PlayerStats
const ACCELERATION = 500
const MAX_SPEED = 80
@@ -21,8 +22,10 @@ onready var animationPlayer = $AnimationPlayer
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")
onready var swordHitbox = $HitboxPivot/SwordHitbox
+onready var hurtBox = $Hurtbox
func _ready():
+ stats.connect("no_health", self, "queue_free")
animationTree.active = true
swordHitbox.knockback_vector = roll_vector
@@ -90,3 +93,9 @@ func attack_aninimation_finished():
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
+
+
+func _on_Hurtbox_area_entered(area):
+ stats.health -= 1
+ hurtBox.start_invincibility(0.5)
+ hurtBox.create_hit_effect()
diff --git a/ActionRPG-HeartBeast/Player/Player.tscn b/ActionRPG-HeartBeast/Player/Player.tscn
index dbe99f3..9d2e0c1 100644
--- a/ActionRPG-HeartBeast/Player/Player.tscn
+++ b/ActionRPG-HeartBeast/Player/Player.tscn
@@ -1,9 +1,10 @@
-[gd_scene load_steps=54 format=2]
+[gd_scene load_steps=56 format=2]
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
[ext_resource path="res://Overlap/Hitbox.tscn" type="PackedScene" id=3]
[ext_resource path="res://Player/SwordHitbox.gd" type="Script" id=4]
+[ext_resource path="res://Overlap/Hurtbox.tscn" type="PackedScene" id=5]
[sub_resource type="CapsuleShape2D" id=1]
radius = 4.0
@@ -641,6 +642,10 @@ graph_offset = Vector2( -10, -78 )
[sub_resource type="CapsuleShape2D" id=40]
height = 12.0
+[sub_resource type="CapsuleShape2D" id=52]
+radius = 5.0
+height = 6.0
+
[node name="Player" type="KinematicBody2D"]
collision_layer = 2
script = ExtResource( 1 )
@@ -698,4 +703,14 @@ script = ExtResource( 4 )
shape = SubResource( 40 )
disabled = true
+[node name="Hurtbox" parent="." instance=ExtResource( 5 )]
+collision_layer = 4
+
+[node name="CollisionShape2D" parent="Hurtbox" index="0"]
+position = Vector2( 0, -4 )
+shape = SubResource( 52 )
+
+[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
+
[editable path="HitboxPivot/SwordHitbox"]
+[editable path="Hurtbox"]
diff --git a/ActionRPG-HeartBeast/Player/PlayerStats.tscn b/ActionRPG-HeartBeast/Player/PlayerStats.tscn
new file mode 100644
index 0000000..161f0ac
--- /dev/null
+++ b/ActionRPG-HeartBeast/Player/PlayerStats.tscn
@@ -0,0 +1,6 @@
+[gd_scene load_steps=2 format=2]
+
+[ext_resource path="res://Stats.tscn" type="PackedScene" id=1]
+
+[node name="PlayerStats" instance=ExtResource( 1 )]
+max_health = 4
diff --git a/ActionRPG-HeartBeast/build/.DS_Store b/ActionRPG-HeartBeast/build/.DS_Store
index 72dc846..43db6ac 100644
Binary files a/ActionRPG-HeartBeast/build/.DS_Store and b/ActionRPG-HeartBeast/build/.DS_Store differ
diff --git a/ActionRPG-HeartBeast/build/web/.DS_Store b/ActionRPG-HeartBeast/build/web/.DS_Store
index a09edd2..6f48151 100644
Binary files a/ActionRPG-HeartBeast/build/web/.DS_Store and b/ActionRPG-HeartBeast/build/web/.DS_Store differ
diff --git a/ActionRPG-HeartBeast/build/web/ActionRPG-web.zip b/ActionRPG-HeartBeast/build/web/ActionRPG-web.zip
index 117e9ea..d6d1d7f 100644
Binary files a/ActionRPG-HeartBeast/build/web/ActionRPG-web.zip and b/ActionRPG-HeartBeast/build/web/ActionRPG-web.zip differ
diff --git a/ActionRPG-HeartBeast/build/web/index.html b/ActionRPG-HeartBeast/build/web/index.html
index 0d880cd..29077cc 100644
--- a/ActionRPG-HeartBeast/build/web/index.html
+++ b/ActionRPG-HeartBeast/build/web/index.html
@@ -139,7 +139,7 @@