Skip to content

Instantly share code, notes, and snippets.

@nickworks
nickworks / AnimMath.cs
Last active August 9, 2022 20:11
A set of low-level functions for procedural animation.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// A set of easy-to-implement animation functions. Compiled by Nick Pattison.
/// </summary>
public static class AnimMath {
/// <summary>
/// A function for lerping between 2 values. Yes, Unity has this Mathf.Lerp() and Vector3.Lerp(),
@nickworks
nickworks / JS Sprite Prototype
Created March 16, 2018 22:35
A simple Sprite prototype for vanilla JS.
function Sprite(url){
this.img = new Image();
this.img.src = url;
this.img.addEventListener("load", ()=>{
this.anchor.x = this.img.width/2;
this.anchor.y = this.img.height/2;
});
this.x = 0;
@nickworks
nickworks / JS Game Boilerplate
Last active March 16, 2018 22:47
Some boilerplate code for setting up a game in vanilla JavaScript
const canvas = document.getElementById("myCanvas");
const gfx = canvas.getContext("2d");
const keycode = {
w: 87,
a: 65,
s: 83,
d: 68,
left: 37,
up:38,