From 92cafad56ad7fda70f02177a21b69a88e7f6de64 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 4 Dec 2023 19:42:47 +0000 Subject: [PATCH] finish new maps --- Body2D.gd | 12 ------ map_select/map_select.tscn | 80 ++++++++++---------------------------- maps/large.gd | 16 ++++++++ maps/rare.gd | 18 +++++++++ maps/sections.gd | 5 --- maps/small.gd | 4 +- sim.gd | 33 +--------------- 7 files changed, 56 insertions(+), 112 deletions(-) create mode 100644 maps/large.gd create mode 100644 maps/rare.gd diff --git a/Body2D.gd b/Body2D.gd index 6fb8a9d..d3fcfea 100644 --- a/Body2D.gd +++ b/Body2D.gd @@ -1,18 +1,7 @@ extends RigidBody2D - -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - func _integrate_forces(state: PhysicsDirectBodyState2D): var contact_count = state.get_contact_count() - #print("aa") for i in range(contact_count): #print("bb") var collider_object = state.get_contact_collider_object(i) @@ -27,6 +16,5 @@ func handle_player_collision(player: Player): $"..".drop() player.drop() - func handle_pool_collision(pool: Pool): $"..".exchange_with(pool) diff --git a/map_select/map_select.tscn b/map_select/map_select.tscn index 8e1889f..b363d50 100644 --- a/map_select/map_select.tscn +++ b/map_select/map_select.tscn @@ -18,82 +18,42 @@ text = "Map Select" label_settings = SubResource("LabelSettings_kd1xo") [node name="Button" type="Button" parent="."] -offset_left = 24.0 -offset_top = 261.0 -offset_right = 199.0 -offset_bottom = 324.0 -text = "RGB" -script = ExtResource("2_ykkpr") -map_path = "res://maps/rgb.tscn" - -[node name="Button2" type="Button" parent="."] -offset_left = 29.0 -offset_top = 186.0 -offset_right = 204.0 -offset_bottom = 249.0 -text = "Source" -script = ExtResource("2_ykkpr") -map_path = "res://maps/source.tscn" - -[node name="Button3" type="Button" parent="."] -offset_left = 25.0 -offset_top = 332.0 -offset_right = 200.0 -offset_bottom = 395.0 -text = "CMY" -script = ExtResource("2_ykkpr") -map_path = "res://maps/cmy.tscn" - -[node name="Button4" type="Button" parent="."] -offset_left = 397.0 -offset_top = 188.0 -offset_right = 572.0 -offset_bottom = 251.0 +offset_left = 26.0 +offset_top = 165.0 +offset_right = 201.0 +offset_bottom = 228.0 text = "Rare" script = ExtResource("2_ykkpr") -map_path = "res://maps/rare.tscn" +map_path = "res://maps/rare.gd" -[node name="Button5" type="Button" parent="."] -offset_left = 213.0 -offset_top = 185.0 -offset_right = 388.0 -offset_bottom = 248.0 -text = "Seperated" +[node name="Button2" type="Button" parent="."] +offset_left = 211.0 +offset_top = 80.0 +offset_right = 386.0 +offset_bottom = 143.0 +text = "Large" script = ExtResource("2_ykkpr") -map_path = "res://maps/seperated.tscn" - -[node name="Button6" type="Button" parent="."] -offset_left = 208.0 -offset_top = 260.0 -offset_right = 383.0 -offset_bottom = 323.0 -text = "RGB Sections" -script = ExtResource("2_ykkpr") -map_path = "res://maps/rgb_sections.tscn" +map_path = "res://maps/large.gd" [node name="Button7" type="Button" parent="."] -offset_left = 35.0 -offset_top = 71.0 -offset_right = 210.0 -offset_bottom = 134.0 +offset_left = 26.0 +offset_top = 250.0 +offset_right = 201.0 +offset_bottom = 313.0 text = "Sections" script = ExtResource("2_ykkpr") map_path = "res://maps/sections.gd" [node name="Button8" type="Button" parent="."] -offset_left = 227.0 -offset_top = 70.0 -offset_right = 402.0 -offset_bottom = 133.0 +offset_left = 24.0 +offset_top = 80.0 +offset_right = 199.0 +offset_bottom = 143.0 text = "Small" script = ExtResource("2_ykkpr") map_path = "res://maps/small.gd" [connection signal="pressed" from="Button" to="Button" method="_on_pressed"] [connection signal="pressed" from="Button2" to="Button2" method="_on_pressed"] -[connection signal="pressed" from="Button3" to="Button3" method="_on_pressed"] -[connection signal="pressed" from="Button4" to="Button4" method="_on_pressed"] -[connection signal="pressed" from="Button5" to="Button5" method="_on_pressed"] -[connection signal="pressed" from="Button6" to="Button6" method="_on_pressed"] [connection signal="pressed" from="Button7" to="Button7" method="_on_pressed"] [connection signal="pressed" from="Button8" to="Button8" method="_on_pressed"] diff --git a/maps/large.gd b/maps/large.gd new file mode 100644 index 0000000..f407342 --- /dev/null +++ b/maps/large.gd @@ -0,0 +1,16 @@ +var root + +func create_map(_root): + root=_root + poolcircle(Vector2(0,0),2000,100,1000,1000,1000) + +func poolcircle(pos: Vector2, radius, count, r,g,b): + for n in range(1,count+1): + var new_pool: Pool = load("res://pool.tscn").instantiate() + var t=(float(n)/count)*3.141*2 + new_pool.position = pos + (Vector2(sin(t),cos(t))*radius) + new_pool.mana_r=r + new_pool.mana_g=g + new_pool.mana_b=b + new_pool.get_node("StaticBody2D/CollisionShape2D2").disabled=true; + root.call_deferred("add_child",new_pool) diff --git a/maps/rare.gd b/maps/rare.gd new file mode 100644 index 0000000..b39c81a --- /dev/null +++ b/maps/rare.gd @@ -0,0 +1,18 @@ +var root + +func create_map(_root): + self.root=_root + poolcircle(Vector2(0,0),0,1,10,0,0) + + poolcircle(Vector2(0,0),2000,100,0,5000,0) + +func poolcircle(pos: Vector2, radius, count, r,g,b): + for n in range(1,count+1): + var new_pool: Pool = load("res://pool.tscn").instantiate() + var t=(float(n)/count)*3.141*2 + new_pool.position = pos + (Vector2(sin(t),cos(t))*radius) + new_pool.mana_r=r + new_pool.mana_g=g + new_pool.mana_b=b + new_pool.get_node("StaticBody2D/CollisionShape2D2").disabled=true; + root.call_deferred("add_child",new_pool) diff --git a/maps/sections.gd b/maps/sections.gd index 59e3c20..49a0fed 100644 --- a/maps/sections.gd +++ b/maps/sections.gd @@ -2,7 +2,6 @@ var root func create_map(root): self.root=root - pass # Replace with function body. poolcircle(Vector2(0,0),200,32,100,0,0) poolcircle(Vector2(600,0),200,32,0,100,0) poolcircle(Vector2(1200,0),200,32,0,0,100) @@ -13,15 +12,11 @@ func create_map(root): poolcircle(Vector2(600,200),2000,100,1000,1000,1000) -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass func poolcircle(pos: Vector2, radius, count, r,g,b): for n in range(1,count+1): var new_pool: Pool = load("res://pool.tscn").instantiate() var t=(float(n)/count)*3.141*2 - print(t) new_pool.position = pos + (Vector2(sin(t),cos(t))*radius) new_pool.mana_r=r new_pool.mana_g=g diff --git a/maps/small.gd b/maps/small.gd index 99513e3..3ab6bec 100644 --- a/maps/small.gd +++ b/maps/small.gd @@ -1,15 +1,13 @@ var root -# Called when the node enters the scene tree for the first time. func create_map(_root): root=_root - poolcircle(Vector2(0,0),2000,100,1000,1000,1000) + poolcircle(Vector2(0,0),200,16,100,100,100) func poolcircle(pos: Vector2, radius, count, r,g,b): for n in range(1,count+1): var new_pool: Pool = load("res://pool.tscn").instantiate() var t=(float(n)/count)*3.141*2 - print(t) new_pool.position = pos + (Vector2(sin(t),cos(t))*radius) new_pool.mana_r=r new_pool.mana_g=g diff --git a/sim.gd b/sim.gd index d3f2782..2bba2a5 100644 --- a/sim.gd +++ b/sim.gd @@ -4,42 +4,11 @@ var spawn_position=Vector2(100,100); # Called when the node enters the scene tree for the first time. func _ready(): - #setup_edge_collisions() pass -func setup_edge_collisions(): - var screen_size = get_viewport_rect().size - - # Create a StaticBody2D for each edge - for i in range(4): - var body = StaticBody2D.new() - body.collision_layer=4 #walls - add_child(body) - - var shape = CollisionShape2D.new() - body.add_child(shape) - - var rect_shape = RectangleShape2D.new() - shape.shape = rect_shape - - # Adjust size and position based on the edge - match i: - 0: # Top - rect_shape.extents = Vector2(screen_size.x / 2, 10) - body.position = Vector2(screen_size.x / 2, 0) - 1: # Bottom - rect_shape.extents = Vector2(screen_size.x / 2, 10) - body.position = Vector2(screen_size.x / 2, screen_size.y) - 2: # Left - rect_shape.extents = Vector2(10, screen_size.y / 2) - body.position = Vector2(0, screen_size.y / 2) - 3: # Right - rect_shape.extents = Vector2(10, screen_size.y / 2) - body.position = Vector2(screen_size.x, screen_size.y / 2) - func _input(event): if event.is_action_pressed("escape"): - get_tree().change_scene_to_file("res://map_select.tscn") + get_tree().change_scene_to_file("res://map_select/map_select.tscn") get_node("/root/Sim").queue_free() if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT: spawn_position=get_global_mouse_position()