Added A Grid

This commit is contained in:
Florian 2025-09-15 19:03:18 +02:00
parent 8b07000d46
commit 9657f330fc
3 changed files with 33 additions and 1 deletions

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://33k5v6skcbsm"] [gd_scene load_steps=5 format=3 uid="uid://33k5v6skcbsm"]
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_qbwya"] [ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_qbwya"]
[ext_resource type="Script" uid="uid://b5fhsy1xlreco" path="res://draw_circle.gd" id="2_2bhor"] [ext_resource type="Script" uid="uid://b5fhsy1xlreco" path="res://draw_circle.gd" id="2_2bhor"]
[ext_resource type="Script" uid="uid://m3vyyfk8gnma" path="res://grid.gd" id="3_2bhor"]
[sub_resource type="CircleShape2D" id="CircleShape2D_5i67w"] [sub_resource type="CircleShape2D" id="CircleShape2D_5i67w"]
radius = 3000.0 radius = 3000.0
@ -20,3 +21,10 @@ radius = 3000.0
[node name="Camera2D" type="Camera2D" parent="."] [node name="Camera2D" type="Camera2D" parent="."]
position = Vector2(47, -3283) position = Vector2(47, -3283)
[node name="Node2D" type="Node2D" parent="."]
script = ExtResource("3_2bhor")
ground_radius = 3000.0
cell_height = 300.0
num_collumns = 36
debug = true

23
grid.gd Normal file
View file

@ -0,0 +1,23 @@
class_name Grid extends Node2D
@export var ground_radius : float
@export var cell_height : float
@export var num_collumns : int
@export var debug : bool
func _draw() -> void:
if !debug:
return
for i in range(10):
draw_arc(Vector2.ZERO, ground_radius + i * cell_height, 0, TAU, 250, Color.SKY_BLUE, 1.0, true);
for i in range(num_collumns):
var angle = i * TAU / num_collumns;
draw_line(Vector2.ZERO, 10000 * Vector2.from_angle(angle), Color.SKY_BLUE);
#func cart_to_sphere(cart : Vector2):
#var x = cart.x; var y = cart.y;
#var radius = sqrt(x*x + y*y);
#var angle = tan(y/x)
## TODO

1
grid.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://m3vyyfk8gnma