completed l4 win condition

This commit is contained in:
2021-12-10 11:08:09 -06:00
parent 111aa4d8ae
commit 0ead947566
11 changed files with 331 additions and 330 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 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 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
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

View File

@@ -10,65 +10,65 @@ 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
var angle = position.angle_to_point(player.position)
if abs(angle) > PI/2:
$AnimatedSprite1.scale.x = -0.563
else:
$AnimatedSprite1.scale.x = 0.563
if player and position.distance_to(player.position) > 1:
velocity = position.direction_to(player.position).normalized() * SPEED
var angle = position.angle_to_point(player.position)
if abs(angle) > PI/2:
$AnimatedSprite1.scale.x = -0.563
else:
$AnimatedSprite1.scale.x = 0.563
if hit == true:
if counter < 15:
if counter % 5 == 0:
$AnimatedSprite1.visible = false
else:
$AnimatedSprite1.visible = true
counter += 1
velocity = Vector2.ZERO
else:
counter = 0
hit = false
if hit == true:
if counter < 15:
if counter % 5 == 0:
$AnimatedSprite1.visible = false
else:
$AnimatedSprite1.visible = true
counter += 1
velocity = Vector2.ZERO
else:
counter = 0
hit = false
velocity = move_and_slide(velocity)
return
velocity = move_and_slide(velocity)
return
func _on_player_detector_body_entered(body: Node) -> void:
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Running'
return
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Running'
return
func _on_player_detector_body_exited(body: Node) -> void:
if body.is_in_group('player'):
player = null
$AnimatedSprite1.animation = 'Idle'
return
if body.is_in_group('player'):
player = null
$AnimatedSprite1.animation = 'Idle'
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
func _on_Player_Detector__Attack_body_entered(body: Node) -> void:
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Jump'
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Jump'
func _on_Player_Detector__Attack_body_exited(body: Node) -> void:
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Running'
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Running'