Skip to content

Instantly share code, notes, and snippets.

@jedStevens
jedStevens / tester.gd
Created May 17, 2017 21:49
Tester script for GodotSteam
extends Node2D
func _ready():
Steam.steamInit()
var running = Steam.isSteamRunning()
print("steam running: ", running)
var persona = Steam.getPersonaName()
print("persona: ", persona)
var friends = Steam.getFriendCount()
// 3D Water Shader
// From: Mr. Jed's Water Shaders | Part 2
shader_type spatial;
uniform sampler2D alb_texture;
uniform sampler2D flow_texture;
uniform float flow_amt = 0.1;
uniform float duration = 1.0;
@jedStevens
jedStevens / ik_skeleton.gd
Created March 13, 2018 18:41
Adds a dual sphere colllision to a two bone chain, needs a target end effector and a target bend effector
tool
extends Skeleton
var ik_root = find_bone("Thigh.Right")
var ik_root2= find_bone("Thigh.Left")
func _ready():
set_process(true)
func _init():
@jedStevens
jedStevens / dropdown.gd
Created April 4, 2018 17:16
Makes a PhysicsBody2D fall through a platform
extends Area2D
const DOULBE_TAP_MAX_TIME = 0.25
const MAX_NAV_DISABLE = 0.4
var double_tap_timer = 0
signal nav_enable
func _ready():
@jedStevens
jedStevens / skater.gd
Created April 21, 2018 17:36
LD41 Player
extends KinematicBody2D
const GRAVITY = 800.0
const PUSH_SPEED = 200
const MAX_SPEED = 500.0
const MIN_OLLIE_FORCE = 200.0
const MAX_OLLIE_FORCE = 350.0
const OLLIE_CHARGE_RATE = 600.0
var OLLIE_FORCE = 0.0
extends Line2D
var _prev_pos = Vector2()
var points_size = 100
func _ready():
set_process(true)
for i in range(points_size):
add_point(Vector2())
@jedStevens
jedStevens / loader.gd
Last active July 3, 2018 14:08
This finds all of the PNGs in a folder
extends Node
var image_db = {}
func _ready():
image_db = load_pngs_from_directory("res://")
print(image_db)
func load_pngs_from_directory(path):
var files = {}
@jedStevens
jedStevens / Items.gd
Created July 4, 2018 17:51
This creates recipes and stores them
extends Node
const NONE = -1
const LOG_ID = 0
const CRAFTING_TABLE_ID = 1
var CRAFTING_TABLE_RECIPE
func _ready():
var Recipe = load("res://recipe.gd")
extends Node
func get_cropped_items():
# Return the items in the cropping zone,
# calculates a crop beforehand
# CROP THE ITEMS
# 1. Find the search Area
var min_x = width
@jedStevens
jedStevens / db_import.gd
Last active July 11, 2018 19:15
Imports a CSV file as a dictionary
func db_import(csv_file,dict_to_append,DICT_HEADERS_LIST):
#EDITED: In order to loop through keys of keys as noted in the
#EDITED section of the first post, EXTRA ARG is called DICT_HEADERS_LIST
var file = File.new()
#creates a new Class instance.
# A var will store this reference as 'file'. (file is not a string)
file.open(csv_file,file.READ)
#the file is read into memory.
# The .csv can now be manipulated with File methods.
var is_header = true