This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends ImmediateGeometry | |
var points = [Vector3(), Vector3(10,0,10), Vector3(0,0,10)] | |
func _process(delta): | |
clear() | |
begin(1, null) | |
for i in range(points.size()): | |
if i + 1 < points.size(): | |
var A = points[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func shuffle_list(list, _seed = null): | |
list = list.duplicate() | |
if _seed: | |
seed(_seed) | |
var shuffledList = [] | |
var indexList = range(list.size()) | |
for i in range(list.size()): | |
var x = randi()%indexList.size() | |
shuffledList.append(list[x]) | |
indexList.remove(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ran_gaussian_2D(): | |
""" | |
ported from the caltech lua one | |
making some optimisations now, many bits are just repeated! | |
STILL NEED TO FIGURE SOME OF THESE EQUATIONS OUT | |
""" | |
var r1 = randf() | |
var r2 = randf() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ran_gaussian_2D(): | |
var r1 = randf() | |
var r2 = randf() | |
var al1 = sqrt(-2 * log(r1)) # part one | |
var al2 = 2 * PI * r2 # part two | |
var x = al1 * cos(al2) | |
var y = al1 * sin(al2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func array_split(array, start = 0, end = -1): | |
var ret = [] | |
if end < 0: | |
end = array.size() + end | |
for i in range(array.size()): | |
if i >= start and i<= end: | |
ret.append(array[i]) | |
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends GridContainer | |
func _ready(): | |
print('running tests...') | |
for child in get_children(): | |
print(self, " found child: ",child) | |
print(child.rect_global_position) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func distance_to_string(distance_m): | |
var suffix = "m" | |
if distance_m > 1000.0: | |
distance_m /= 1000.0 | |
suffix = "km" | |
var txt = "%*.*f m" % [7,1,distance_m] | |
txt += " %s" % suffix | |
return txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func my_rotate_towards_lerp(target, delta): | |
var deg360 = deg2rad(360.0) # is 360 degrees but in radians | |
var deg180 = deg2rad(180.0) | |
var node = Node2D.new() #create a new node | |
node.position = global_position #at the same position | |
node.look_at(target) #get it to look instead! (missing functions in godot) | |
#adding 180 degrees is to do with needing to find left and right, like -180 to 180 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func my_rotate_towards_lerp(target, delta): | |
var deg360 = deg2rad(360.0) # is 360 degrees but in radians | |
var deg180 = deg2rad(180.0) | |
var node = Node2D.new() #create a new node | |
node.position = global_position #at the same position | |
node.look_at(target) #get it to look instead! (missing functions in godot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func _ready(): | |
print("start tests...") | |
var dispose # i put this here, to prevent some clever compiler from realising these values are not used | |
var start_time = OS.get_ticks_msec() | |
for i in range(1,1000000): | |
dispose = 15629/i | |
var total_time = OS.get_ticks_msec() - start_time |