spacevroom

A SkyRoads clone with only one boring "level" written in Godot Engine version 3.
git clone https://kaka.farm/~git/spacevroom
Log | Files | Refs | LICENSE

Saucer.gd (1678B)


      1 tool
      2 extends Spatial
      3 
      4 
      5 
      6 onready var small_spheres: = $CSGSphere/SmallSpheres
      7 
      8 
      9 export var radius_of_little_spheres: float = 0.1 setget setget_radius
     10 export var number_of_little_spheres: int = 3 setget setget_number
     11 export var distance_from_axis_of_little_spheres: float = 0.34 setget setget_distance
     12 export var height_of_little_spheres: float = 0.924 setget setget_height
     13 
     14 
     15 
     16 func _ready() -> void:
     17 	set_spheres()
     18 
     19 
     20 func setget_height(height):
     21 	height_of_little_spheres = height
     22 #	set_spheres()
     23 
     24 
     25 func setget_distance(distance):
     26 	distance_from_axis_of_little_spheres = distance
     27 #	set_spheres()
     28 
     29 
     30 func setget_number(number):
     31 	number_of_little_spheres = number
     32 #	set_spheres()
     33 
     34 
     35 func setget_radius(radius):
     36 	radius_of_little_spheres = radius
     37 #	set_spheres()
     38 
     39 
     40 func set_spheres() -> void:
     41 	remove_existing_spheres()
     42 	add_little_spheres()
     43 
     44 
     45 func remove_existing_spheres() -> void:
     46 	print_debug(small_spheres)
     47 	var small_sphere_children: = small_spheres.get_children()
     48 	for small_sphere in small_sphere_children:
     49 		small_spheres.remove_child(small_sphere)
     50 
     51 
     52 func add_little_spheres() -> void:
     53 	var saucer_spatial_material: SpatialMaterial = load("res://SaucerMaterial.tres")
     54 
     55 	for i in range(number_of_little_spheres):
     56 		var x: = distance_from_axis_of_little_spheres * sin(TAU * i/number_of_little_spheres)
     57 		var z: = distance_from_axis_of_little_spheres * cos(TAU * i/number_of_little_spheres)
     58 		var sphere: = CSGSphere.new()
     59 		sphere.translation.x = x
     60 		sphere.translation.z = z
     61 		sphere.translation.y = height_of_little_spheres
     62 		sphere.radius = radius_of_little_spheres
     63 		sphere.material = saucer_spatial_material
     64 		small_spheres.add_child(sphere)
     65 		print_debug("%s %s" % [x, z])