Hello fellows!
I'm newbie in Godot Script Language and still doing little improvments in learning it. Previously i worked at GML (Game Maker)
My question is quite simple but i don't know how to make it in Godot Script right.
I have primitive level generating algorythm thats creates objects in scene on grid (wall, floor)
It is creates structures like that:
It is copies of 2 objects (Black wall block and Green floor block)
The question is:
I create function with 2d coordinates of circle (center and radius), i need to change only Floor in radius to different type of tile (for example Red block) How can i do it in Godot Script?
How to check objects within Radius?
Update to Discussion.
I have 2d array system thats creates Tilemap.
How can i implement this type of Circle search in 2D Array? Is it possible?
If Radius == 1
If Radius == 2
Welcome to the forums @Hutukawa!
I haven't done this myself, but I think you use something like the following to get the whole number coordinates around a given point:
var radius = 2
var center_point = Vector2(10, 10)
var circle_resolution = 16
var current_rotation = 0;
var rotation_step = deg2rad(360 / circle_resolution)
for i in range(0, circle_resolution):
var offset = Vector2(cos(current_rotation), sin(current_rotation))
var working_point = center_point + offset
# round to the nearest whole number
working_point = working_point.round()
# do whatever you need with the position here!
print ("Point: ", working_point)
current_rotation += rotation_step
2 years later
Megalomaniak added the Godot Help tag .