Code cleanup and minor fixes to Level 3

This commit is contained in:
VoidTwo
2021-12-09 04:08:28 -06:00
parent 9dce1e02cf
commit 2147d38874
27 changed files with 418 additions and 437 deletions

View File

@@ -10,49 +10,49 @@ var counter: int = 0
func _physics_process(_delta: float) -> void:
velocity = Vector2.ZERO
velocity = Vector2.ZERO
if player and position.distance_to(player.position) > 1:
velocity = position.direction_to(player.position).normalized() * SPEED
if hit == true:
if counter < 15:
if counter % 5 == 0:
$AnimatedSprite.visible = false
else:
$AnimatedSprite.visible = true
counter += 1
velocity = Vector2.ZERO
else:
counter = 0
hit = false
if player and position.distance_to(player.position) > 1:
velocity = position.direction_to(player.position).normalized() * SPEED
velocity = move_and_slide(velocity)
return
if hit == true:
if counter < 15:
if counter % 5 == 0:
$AnimatedSprite.visible = false
else:
$AnimatedSprite.visible = true
counter += 1
velocity = Vector2.ZERO
else:
counter = 0
hit = false
velocity = move_and_slide(velocity)
return
func _on_player_detector_body_entered(body: Node) -> void:
if body.is_in_group('player'):
player = body
return
if body.is_in_group('player'):
player = body
return
func _on_player_detector_body_exited(body: Node) -> void:
if body.is_in_group('player'):
player = null
return
if body.is_in_group('player'):
player = null
return
func _on_hitbox_area_entered(area: Area2D) -> void:
if area.is_in_group('player_weapon_1'):
health -= 1
hit = true
elif area.is_in_group('player_weapon_2'):
health -= 2
hit = true
if area.is_in_group('player_weapon_1'):
health -= 1
hit = true
elif area.is_in_group('player_weapon_2'):
health -= 2
hit = true
if health <= 0:
call_deferred('queue_free')
return
if health <= 0:
call_deferred('queue_free')
return