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
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 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
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 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 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
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
var coll_dict_data1 = [ | |
["player", | |
"1000000000000000", "0000111111111111"], | |
["playerbullet", | |
"0100000000000000", "0000101110111011"], | |
["playerbulletclash", | |
"0010000000000000", "0000111111111111"], | |
["enemy", | |
"0000100000000000", "1111000011111111"], | |
["enemybullet", |
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
mat3 GetTBN(); | |
vec3 GetBumpedNormal(mat3 tbn, vec2 texcoord); | |
vec2 ParallaxMap(mat3 tbn); | |
Material ProcessMaterial() | |
{ | |
mat3 tbn = GetTBN(); | |
vec2 texCoord = ParallaxMap(tbn); | |
Material material; |
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
if pcall(function () | |
print('test1') | |
error() | |
end)then | |
print('test2') | |
else | |
print('test3') | |
end |