Skip to content

Instantly share code, notes, and snippets.

View RichardEllicott's full-sized avatar

Richard Ellicott RichardEllicott

  • Luton
View GitHub Profile
# MIT License
#
# Copyright (c) 2018 Jelle Hermsen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@RichardEllicott
RichardEllicott / gist:bf9d539589844541a4fea6c0b4f03943
Created January 27, 2021 21:27
Doom2's E1M1 extracted to the UDMF format (using gzdoombuilder)
namespace = "zdoom";
thing // 0
{
x = -488.000;
y = -48.000;
angle = 90;
type = 1;
coop = true;
dm = true;
single = true;
extends Node
var inventorys = {} # NEW
func _ready():
LoadDictionary("res://Items/Armor/", "Armor")
LoadDictionary("res://Items/Consumable/", "Consumables")
LoadDictionary("res://Items/Resource/", "Resources")
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()
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:
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()
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
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)
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
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