ape-ame/player-row.gd

67 lines
1.8 KiB
GDScript3
Raw Permalink Normal View History

2024-05-06 10:05:42 -04:00
extends "res://player.gd"
2024-05-09 14:23:34 -04:00
var num_quares = 0
var max_quares = 3
var exagons = 0
var quare_ability = preload("res://quare_ability.tscn")
2024-05-06 14:09:14 -04:00
func update_animation():
if moving:
2024-05-07 14:29:47 -04:00
$AnimatedSprite2D.play("moving")
2024-05-06 14:09:14 -04:00
else:
2024-05-07 14:29:47 -04:00
$AnimatedSprite2D.play("idle")
2024-05-06 14:09:14 -04:00
2024-05-06 10:05:42 -04:00
func _ready():
2024-05-09 14:23:34 -04:00
for i in range(max_quares):
$"../".get_node("%Ability").add_child(quare_ability.instantiate())
2024-05-06 10:05:42 -04:00
update_animation()
if config.load("user://settings.cfg") == OK:
absolute_movement = not config.get_value("config", "relative_controls")
func _input(event):
2025-02-07 13:37:10 -05:00
if event.is_action_pressed("primary_fire"):
2024-05-06 10:05:42 -04:00
if num_quares >= max_quares:
notifier.notify("All Quares in Use!")
return
if not $"../CollisionCheck".is_clear(get_global_mouse_position(), 60):
$"../CollisionCheck".flash()
notifier.notify("Too Close!")
return
2025-02-05 21:15:12 -05:00
for child in $"../".get_node("%Ability").get_children():
if child.value == 0 and not child.animating:
child.value = 100
2024-05-06 10:05:42 -04:00
num_quares += 1
var new_quare = quare.instantiate()
new_quare.position = get_global_mouse_position()
$/root/Node2D.add_child(new_quare)
new_quare.name = "Quare"
#if event.is_action_pressed("secondary_fire"):
#if exagons > 1:
#exagons = 1
#if exagons <= 0:
#notifier.notify("No Exagons!")
#return
#
#if not $"../CollisionCheck".is_clear(get_global_mouse_position()):
#$"../CollisionCheck".flash()
#notifier.notify("Too Close!")
#return
#exagons -= 1
#var new_exagon = exagon.instantiate()
#new_exagon.position = get_global_mouse_position()
#$/root/Node2D.add_child(new_exagon)
#new_exagon.name = "Exagon"
##$Gun.shoot()
2024-05-06 10:05:42 -04:00
func aquire_quare():
2024-05-09 14:23:34 -04:00
for child in $"../".get_node("%Ability").get_children():
if child.value == 100 and not child.animating:
child.start_countdown(3)
break
2024-05-06 10:05:42 -04:00
await get_tree().create_timer(3).timeout
num_quares -= 1
$AbilityRechargeFX.play()