TODO pick nearest target

main
Just Dzhi 2023-10-01 02:10:12 +04:00
parent 0d30fb29be
commit a81c6b9afd
3 changed files with 16 additions and 12 deletions

View File

@ -8,16 +8,6 @@
config_version=4
_global_script_classes=[ {
"base": "EditorVCSInterface",
"class": "GitAPI",
"language": "NativeScript",
"path": "res://addons/godot-git-plugin/git_api.gdns"
} ]
_global_script_class_icons={
"GitAPI": ""
}
[application]
config/name="LD54"
@ -49,7 +39,7 @@ version_control_plugin_name="GitAPI"
[gdnative]
singletons=[ "res://addons/godot-git-plugin/git_api.gdnlib" ]
singletons=[ ]
[global]

View File

@ -24,3 +24,13 @@ func area_exited(area):
func _physics_process(_delta):
get_input()
velocity = move_and_slide(velocity * speed_multiplier)
_choose_target()
func _choose_target():
var enemies = get_tree().get_nodes_in_group("enemy")
enemies.sort_custom(self, "_sort")
for enemy in enemies:
enemies.front().scale.x = 1 #TODO
func _sort(a, b):
return a.position < b.position

View File

@ -72,11 +72,15 @@ shape = SubResource( 3 )
[node name="Enemies" type="Node2D" parent="View"]
[node name="TrashCan" parent="View/Enemies" instance=ExtResource( 13 )]
[node name="TrashCan" parent="View/Enemies" groups=["enemy"] instance=ExtResource( 13 )]
[node name="Bat" parent="View/Enemies" instance=ExtResource( 14 )]
z_index = 1
[node name="Bat2" parent="View/Enemies" instance=ExtResource( 14 )]
position = Vector2( 142, 54 )
z_index = 1
[node name="Player" parent="View" instance=ExtResource( 5 )]
position = Vector2( 46, 42 )
z_index = 1