Skip to content

Instantly share code, notes, and snippets.

View lucashaley's full-sized avatar

Lucas Haley lucashaley

View GitHub Profile
@xenobrain
xenobrain / sat.rb
Last active October 24, 2024 18:41
SAT
def create_vertices rect
x = rect.x; y = rect.y
w = rect.w; h = rect.h
cx = x + w * 0.5; cy = y + h * 0.5
sin = Math.sin (rect.angle || 0.0).to_radians; cos = Math.cos (rect.angle || 0.0).to_radians
[
[(x - cx) * cos - (y + h - cy) * sin + cx, (x - cx) * sin + (y + h - cy) * cos + cy], # Top Left
[(x + w - cx) * cos - (y + h - cy) * sin + cx, (x + w - cx) * sin + (y + h - cy) * cos + cy], # Top Right
[(x + w - cx) * cos - (y - cy) * sin + cx, (x + w - cx) * sin + (y - cy) * cos + cy], # Bottom Right
[(x - cx) * cos - (y - cy) * sin + cx, (x - cx) * sin + (y - cy) * cos + cy] # Bottom Left
//
// CGPoint+Centroid.swift
//
// Created by Robert Ryan on 5/19/20.
// Copyright © 2020 Robert Ryan. All rights reserved.
//
// See https://stackoverflow.com/a/61884774/1271826
import Foundation
@tomkail
tomkail / ExtendedScriptableObjectDrawer.cs
Last active May 30, 2025 14:45
Displays the fields of a ScriptableObject in the inspector
// Developed by Tom Kail at Inkle
// Released under the MIT Licence as held at https://opensource.org/licenses/MIT
// Must be placed within a folder named "Editor"
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
@amirrajan
amirrajan / sound_thread.rb
Created February 19, 2017 23:43
Play sound on a separate thread
def play_forward_sound_thread
NSThread.detachNewThreadSelector :play_forward_sound, toTarget: self, withObject: nil
end
def play_forward_sound context = nil
#play sound code here
end
@LotteMakesStuff
LotteMakesStuff / ReadOnlyAttribute.cs
Created January 17, 2017 00:17
ReadOnly property drawer for Unity~ Add a [ReadOnly] attribute to a property to make it show up as read only in the inspector
// NOTE DONT put in an editor folder
using UnityEngine;
public class ReadOnlyAttribute : PropertyAttribute { }
@jwygralak67
jwygralak67 / roll.html
Last active October 21, 2024 12:06
A simple dice roller for gaming or whatever. Uses html, css, & javascript. Self-contained in one html file. Can be saved and run locally.
<html><head>
<meta name="viewport" content="width=480">
<style>
input {border-style: none; border-bottom-style: solid; border-width:thin;}
div {border:solid thin black; margin: 0.5em; padding: 0.5em; border-radius: 1em; background: #f7f7f7;}
.die {border:solid thin black; margin: 1px; padding: 1px; border-radius: 5px; display: inline-block;}