Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Ellicott RichardEllicott

View GitHub Profile
@RichardEllicott
RichardEllicott / gist:bf9d539589844541a4fea6c0b4f03943
Created Jan 27, 2021
Doom2's E1M1 extracted to the UDMF format (using gzdoombuilder)
View gist:bf9d539589844541a4fea6c0b4f03943
namespace = "zdoom";
thing // 0
{
x = -488.000;
y = -48.000;
angle = 90;
type = 1;
coop = true;
dm = true;
single = true;
View gist:92fdc86af74449f5baf6a129aeb14cfc
extends Node
var inventorys = {} # NEW
func _ready():
LoadDictionary("res://Items/Armor/", "Armor")
LoadDictionary("res://Items/Consumable/", "Consumables")
LoadDictionary("res://Items/Resource/", "Resources")
View tilemaptest.gd
tool
extends Node
# dummy variable, click var in editor to update
export var tool_update = false setget set_tool_update
func set_tool_update(new_value):
tool_update = new_value
if tool_update:
tool_update()
View gist:3edd0bbaedda7fd16f06dd429e4ad302
func flood_fill(x,y,val, ttl = 1000):
var tile_map = $TileMap
var start_val = tile_map.get_cell(x,y)
if start_val != val:
var cells_to_check = [[x,y]] # add cells like [x,y]
while cells_to_check.size() > 0 and ttl > 0:
View gist:0e7fd7581fe7942e58bfa4e7c303fc60
func _ready():
var test_iterations = 1000000
print("start tests...")
var dispose # i put this here, to prevent some clever compiler from realising these values are not used
var counter = test_iterations
var start_time = OS.get_ticks_msec()
View gist:ee09d45cea8fd63a720b55c5af783f50
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
View gist:809899ec6f52429e8dc6ba7996b5daef
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)
View gist:db35be4e940c496d9dd709470fa17a5d
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
View gist:ed537acabfaba62a466463663bb3fd5b
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
@RichardEllicott
RichardEllicott / GridContainerTest.gd
Last active Jun 27, 2019
showing iterating child nodes of GridContainer to produce the coordinates of the rectangles
View GridContainerTest.gd
extends GridContainer
func _ready():
print('running tests...')
for child in get_children():
print(self, " found child: ",child)
print(child.rect_global_position)