# Line2D Bracket Generation

I am attempted to use Line2D to draw a bracket for a tournament based on the number of applicants. I want it to look like the following:

I would like some sort of algorithm to add a point for each applicant in a vertical line, and then build in from there, but I am unsure of how to do this without the entire thing being connected looking like a bunch of boxes. What would be the most ideal way of creating this?

I’m not sure, I understand this…? You already know about Line2D, so where exactly are you facing any problems here?

I was struggling to find a way to add the entire bracket without every single point being connected, but I ended up figuring it out

Nice! If you got the time, maybe share your solution here? You never know who else might have the same (or a similar) problem and stumbles across this post.

Sure thing! Below if my current implementation. If you have any tips on how to optimize please let me know:

extends VBoxContainer

var sizeAnchor = 8
var participants = 8
var newParticipants
var line
var playerName
var newLine = Vector2(100, 100)
var stepY = 400

func based_log(base, x) → float:
return (log(x) / log(base))

func next_log(base, x) → int:
var first = based_log(base, x)
return base ** ceil(first)

playerName = Label.new()
playerName.position.x = playerName.position.x + 300
print(playerName.position.x)
playerName.text = “SHEET”

``````while participants != 1:
for i in participants / 2:
line = Line2D.new()
# First Round
line.add_point(Vector2(newLine.x + 100, newLine.y + stepY*i))
line.add_point(Vector2(newLine.x + 100, newLine.y * 3 + stepY*i))
line.add_point(Vector2(newLine.x, newLine.y * 3 + stepY*i))

newLine.x = newLine.x + 100
newLine.y = newLine.y * 2
stepY = stepY * 2
newParticipants = participants / 2
participants = newParticipants