# 4x Space Procgen

4.2 Stable

### Question

I’m working on a 4x Space Strategy Game and everything is going well untill I got into creating the procgen for the starmap, I realized I have no Idea how to implement it. Well, to be fair I tried a lot of different approach in placing the stars(containing the planets) on a random position but everything feels wrong to me, I may be missing something or I am just doing it all wrong.

I’m trying to do something like this.

Am I supposed to use noise? Cellular? And instantiate the scenes(stars)?

Nvm, I figured it out myself now the starlane is my next problem.

func _positioner():
if Star_count > round((widthheight)/star_distance):
print(“Too Many Stars or The distance are too great!”)
pass
else:
print(Star_count, " / ", round((width
height)/star_distance))
if not Star_count == starsPos_Counter:
for i in Star_count:

``````  		var x = 1
var y = 1

starsPos_Counter += 1
var positioner = _star_pos_arbiter()
if positioner == null:
debug_cycles_pos += 1
positioner = _star_pos_arbiter()
else:
starsDic[i] = sphere
sphere.position = positioner
for j in star_distance*star_distance:
if x == star_distance and not y == star_distance:
x = 0
y += 1
else:
if not x == star_distance:
x += 1
else:
pass

var bridge = Vector2(positioner.x - star_distance/2, positioner.y - star_distance/2)
var pos = Vector2(bridge.x + x, bridge.y + y)
starsDic_pos[pos] = "Occupied"

if sphere.get_parent() == null:
print("starsDic: ", starsDic.size())
print("starsDic_pos: ", starsDic_pos.size())
``````

func _star_pos_arbiter():
var rander = Vector2(randi_range(-width, width), randi_range(-height, height))

if starsDic_pos.has(rander) and starsDic_pos[rander] == “Occupied”:
return null
else:
if rander == Vector2(0, 0):
return null
else:
return rander

thank you, you’re a life saver​:crab:

Btw, I don’t know what this forum use is it the ` or something it just turned into that jumbled form

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.