#Making generated lines?

1 messages · Page 1 of 1 (latest)

real fractal
#

Here is a quick reference for what I am talking about, is there a way in my sprite sheet i can say that these points should be the beginning and end of the lines

#

the power lines will be randomly placed, so they need to be connected and i dont want to make a sprite sheet of lines

true rapids
#

You can use a draw_line() call in a node's _draw() function.
Altho you may want a separate node to draw the lines instead of leaving it to the pole (or at least have the pole use a different node to define where the points go)

You can either manually define each position as a pair of coordinates or use plain Node2Ds like "WireConnectionPoint" and use their position.

extends Node2D
class_name WireConnector

##Set this to the other end. Leave it empty for the receiving end.
@export var target_connector: WireConnector

##Used to draw the wire
func _draw()
  ##Do not draw anything if there is no target.
  if target_connector == null: return

  var target_point: Vector2 = to_local(target_connector.global_position)
  var width: float = 2

  draw_line(Vector2.ZERO, target_point, Color.BLACK, width)
#

You can also programatically look up every connector or even define a coordinate in the pole itself and use that point.
There's plenty of ways to do this.

real fractal
true rapids
#

There's a bunch of draw_* functions.

real fractal
#

this is my layout for "everything" i need to work out

#

and how im going to determine which one connects to which

#

i might just see if the Y values are different, if they are then i check which ones closest on the nearest Y value

true rapids
#

You could do it by position.
Each pole connects its blue point to the nearest pole's red point to its right.

#

With that i mean you can do it by code.

real fractal
#

yea

#

if i do it by closest, itll just connect them, which i dont mind still looks neat
but if i sort by closest Y value then itll look more uniform

#

i just dont know if there could be a better solution than this