Skip to content

Instantly share code, notes, and snippets.

@cbscribe
cbscribe / osx-for-hackers.sh
Created January 24, 2017 05:33 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@cbscribe
cbscribe / find_closest_point.py
Last active January 28, 2017 06:18
find the closest point on a line to a given point
def get_closest_point(a, b, p, clamp_to_segment=True):
""" get closest point on line segment [ab] to point p """
ab = b - a # vector from a -> b
ap = p - a # vector from a -> p
ab2 = ab.x ** 2 + ab.y ** 2 # length of ab
ap_dot_ab = ap.x * ab.x + ap.y * ab.y # dot product (project ap onto ab)
t = ap_dot_ab / ab2
if clamp_to_segment:
if t < 0:
t = 0
@cbscribe
cbscribe / 8_way_input.gd
Last active April 8, 2018 20:21
gdscript - quick input vector (8 way)
var vect = Vector2()
vect.x = Input.is_action_pressed("right") - Input.is_action_pressed("left")
vect.y = Input.is_action_pressed("down") - Input.is_action_pressed("up")
vect = vect.normalized()
@cbscribe
cbscribe / Ocean.tet
Created February 14, 2017 07:17
Base16 Ocean theme for Godot
[color_theme]
background_color="211F26"
base_type_color="bf616a"
brace_mismatch_color="ffff3333"
caret_color="ffffffff"
comment_color="65737e"
current_line_color="ff2d2f31"
engine_type_color="a3be8c"
function_color="8fa1b3"
@cbscribe
cbscribe / transition.gd
Created February 14, 2017 18:58
Scene transition - fade animation
# global - scene manager also scene with only anim and black texture
func change_stage(stage_path):
if is_changing: return
is_changing = true
get_tree().get_root().set_disable_input(true)
# fade to black
get_node("anim").play("fade_in")
@cbscribe
cbscribe / create_timer.gd
Last active February 14, 2017 19:16 — forked from brunosxs/create_timer.gd
Godot Quick Tips 01: The create_timer() helper for waiting X seconds
# Available only in the 2.2 legacy branch and posterior versions
func _ready():
# The old way:
print("HELLO") # Code before the yield
# Setting up the yield:
var t = Timer.new() # Create a new Timer node
t.set_wait_time(5.5) # Set the wait time
add_child(t) # Add it to the node tree as the direct child
@cbscribe
cbscribe / greyscale.shader
Created February 21, 2017 05:20
Godot greyscale shader
// use on 1x1 white pixel texframe
// shader properties
uniform float brightness = 0.5;
color pixel_color = vec4(texscreen(SCREEN_UV), 1);
COLOR.rgb = vec3(dot(pixel_color.rgb, vec3(brightness, brightness, brightness)));
@cbscribe
cbscribe / drawmaze.py
Created March 22, 2017 03:35
Draw a maze to solve with the turtle!
import turtle
t = turtle.Pen()
t.speed(0)
t.width(5)
turtle.tracer(0)
# goto start
t.up()
t.goto(-300, 300)
t.down()
class Explosion(pygame.sprite.Sprite):
def __init__(self, center, size):
pygame.sprite.Sprite.__init__(self)
self.size = size
self.image = explosion_anim[self.size][0]
self.rect = self.image.get_rect()
self.rect.center = center
self.frame = 0 # set frame to 0 (frame will increment based on frame rate)
self.last_update = pygame.time.get_ticks() # set last_update to gametime in miliseconds (since object initaited)
self.frame_rate = 50
@cbscribe
cbscribe / KinematicPlatformer2d.gd
Created August 1, 2017 03:05 — forked from XANOZOID/KinematicPlatformer2d.gd
Godot easy and composable slopes platformer code (DEMO: https://media.giphy.com/media/iPQssOxSZ61Zm/giphy.gif )
# ____________LICENSE____________
# (See license.txt or the *maintained* link included for more details )
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# ______________________________
# Please credit "Abe Noll(forgotten-king)", the writer of this script and implementation.
# For what MPL-2.0 covers, I would appreciate if you went the extra mile to include a link in the source
# to any of the changes and fixes you made back to this gist, and also to leave a link on