From b97ebd793eb17032f3929f307dfe644b17714619 Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Sat, 13 Apr 2024 21:50:12 +0700 Subject: bare bones ai, softlock issues --- Scripts/Generator.gd | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'Scripts/Generator.gd') diff --git a/Scripts/Generator.gd b/Scripts/Generator.gd index c236f7c..834e07b 100644 --- a/Scripts/Generator.gd +++ b/Scripts/Generator.gd @@ -23,36 +23,54 @@ func generate(): var count : int = randi_range(min_nodes, max_nodes) print(count) + var new_nodes : Array[NumberNode] + for i in count: var is_big : bool = false - if randf() < 0.1: + if randf() < 0.06: is_big = true var new : NumberNode = numbernode.instantiate() if is_big: - new.position = Vector2(randf_range(30, 1250), randf_range(30, 690)) + new.position = Vector2(randf_range(400, 900), randf_range(200, 400)) # disgusting hardcoded values, or not really? else: - new.position = Vector2(randf_range(30, 1250), randf_range(30, 690)) # disgusting hardcoded values, or not really? - + new.position = Vector2(randf_range(30, 1250), randf_range(30, 690)) + get_node(GlobalVariables.NODE).add_child(new) - var shape_cast : ShapeCast2D = new.get_node("ShapeCast2D") - - if !is_big: check_position_and_retry(new, shape_cast, 0) + var shape_cast : ShapeCast2D + + if !is_big: + shape_cast = new.get_node("ShapeCast2D") + else: + new.get_node("NumberArea2D").set_collision_layer_value(1, false) + new.get_node("NumberArea2D").set_collision_layer_value(3, true) + shape_cast = new.get_node("ShapeCast2D2") + + check_position_and_retry(new, shape_cast, 0) new.value = randi_range(0, 10) if is_big: - new.value *= 20 + new.value = new.value + 10 * 5 new.modifier_operation = clamp(abs(roundi(randfn(0, 10))) - 7, 0, 4) - + if new.modifier_operation == NumberNode.Operations.DIVISION: new.modifier = randi_range(1, 3) else: new.modifier = snapped(randf_range(-3, 3), 0.1) - + + if is_big: + new.scale = Vector2(1.4, 1.4) + new.get_node("NumberArea2D").set_collision_layer_value(1, true) + new.get_node("NumberArea2D").set_collision_layer_value(3, true) + new.update_visuals() + #new_nodes.append(new) + + #for n in new_nodes: + # n.softlock_check() func check_position_and_retry(node : NumberNode, shape_cast : ShapeCast2D, tries : int = 0): shape_cast.force_shapecast_update() @@ -60,9 +78,10 @@ func check_position_and_retry(node : NumberNode, shape_cast : ShapeCast2D, tries var collision_count = shape_cast.get_collision_count() print(node.name + " " + str(collision_count)) if collision_count > 1: - node.queue_free() # TODO: failed? screw you! DIE!!!! + node.queue_free() # TODO: failed? screw you! DIE!!!! NO RETRIES FOR YOU, FAILURE #tries += 1 - + tries = tries # compiler won't complain + #node.position = Vector2(randf_range(0, 1280), randf_range(0, 720)) # disgusting hardcoded values, or not really? #shape_cast.position = Vector2.ZERO #shape_cast.global_position = node.global_position -- cgit v1.2.3