How do i make an infinite generating 2d world in circle layers, each one having its own level and it gets harder to survive(the enemies get harder to defeat, depending of the level of the layer) the further you are from the middle of the circle.
It’s relatively easy to calculate distances, so if the spawn point is at the origin, distance from the spawn point gives you your difficulty rating. You can quantize that if you like:
const SPAWN_AREA_RADIUS: float = 120.0
const LEVEL_WIDTH: float = 80.0 # Shell thickness of the level.
func get_level(pos: Vector2) -> int:
var dist_from_origin = pos.length()
if dist_from_origin < SPAWN_AREA_SIZE:
return 0
return int((dist_from_origin - SPAWN_AREA_RADIUS) / LEVEL_WIDTH) + 1
You can procedurally generate tilemaps (there are tutorials for that, I believe), so you’d either pregen everything at level start, or you’d generate new chunks of the map if the player wanders in to them.
Thank you so much. Do you have any tutorial recommendations. I just want an infinite and the barriers of the zones to be of different colors to indicate entering a new layer. I’m pretty new to godot
I haven’t used any of the tutorials, so I don’t know what to recommend, but going through some of the Godot docs “getting started” tutorials would probably help.
I like this concept. I was thinking of something similar a while ago.
I think you could have some fun with how you motivate the player to move further out. If it’s a survival game then maybe you have a death field pushing them out or rewards start falling off as the player progresses. Whatever that looks like for you, I think it’s worth trying out!