Skip to content

Instantly share code, notes, and snippets.

@jaburns
jaburns / import-spritesheet.jsfl
Created November 26, 2014 19:18
JSON Spritesheet Import JSFL
/**
* Json Frame Array Sprite Sheet Importer
*
* Creates a new MovieClip in the library, then for each frame in the imported spritesheet
* animation this script will create a bitmap-filled shape on the timeline of the newly-created
* movieclip.
*/
var LIBRARY_FOLDER = 'imported-sprites';
var dom = fl.getDocumentDOM ();
@jaburns
jaburns / game-physics-conversion.md
Last active August 29, 2015 14:14
Game "physics" constants conversion rules

Game "physics" constants conversion rules

Converting from dt=A to dt=B

Per-frame scale values (i.e. vx *= Z)
Z_new = Z ^ (B/A)
Acceleration values (i.e. vx += Z)
Z_new = Z * (B/A)^2
@jaburns
jaburns / index.html
Created February 6, 2015 23:45
Laggy socket.io hello world
<!DOCTYPE html>
<html>
<style>
body { background: #fff; }
#paper { background: #ccc; }
</style>
<body>
<canvas id="paper" width="800" height="600"></canvas>
</body>
<script src="/socket.io/socket.io.js"></script>
@jaburns
jaburns / gist:31f0dfa1af8656de3759
Created February 18, 2015 00:13
Sound detector
'use strict';
var playerModes = require('../../game/player').modes;
/**
* This module exports a single function that checks a game state and
* its latest diff for game sound triggers and plays the appropriate
* sounds on the provided AudioPlayer object.
*/
@jaburns
jaburns / Main.hs
Last active August 29, 2015 14:16
SDL Pixel Pushing comparison
module Main (
main
) where
import Control.Monad.State
import Control.Monad.Reader
import Data.Word
import Foreign
import Graphics.UI.SDL
@jaburns
jaburns / Makefile
Last active August 29, 2015 14:16
:|
default: all
all: public/index.html
public/index.html: index.html
cpp index.html | sed '/^#.*/d' > public/index.html
@jaburns
jaburns / gdrive-invert-icons
Created March 30, 2015 21:04
Force inverted tray icons for OSX Google Drive
#!/usr/bin/env bash
cd /Applications/Google\ Drive.app/Contents/Resources
for file in $(find . -depth 1 | grep 'inverse.*png'); do
echo "Fixing $file ..."
cp "$file" "$(printf "$file" | sed 's/-inverse//')"
done
echo 'Done!'
@jaburns
jaburns / StarlingAtlasSlicer.cs
Last active August 29, 2015 14:20
Starling sprite animation atlas slicer for Unity
using System;
using System.Collections.Generic;
using System.Xml;
using UnityEditor;
using UnityEngine;
public class StarlingAtlasSlicer
{
[MenuItem("CONTEXT/TextureImporter/Slice Sprite Using XML")]
static public void SliceUsingXML(MenuCommand command)
@jaburns
jaburns / CubicSplineWalker.cs
Created August 15, 2015 23:19
Estimates the length of a cubic Bezier spline and provides an interface to walk it at a constant speed.
using UnityEngine;
using System;
using System.Collections.Generic;
public class CubicSplineWalker
{
readonly Vector2 _anchor0;
readonly Vector2 _control0;
readonly Vector2 _control1;
readonly Vector2 _anchor1;
@jaburns
jaburns / playground.html
Created August 25, 2015 18:01
Shim for messing around with effects
<!DOCTYPE html>
<html>
<body>
<canvas id="paper" width="1024" height="768"></canvas>
<script>
// ---------------------------------------------------------------------------
var canvas = document.getElementById("paper");
var ctx = canvas.getContext("2d");
var mouse = {}, keys = {};
canvas.addEventListener('mousemove', function(e) {