Skip to content

Instantly share code, notes, and snippets.

@leegrey
leegrey / LGVector2D.cpp
Created June 11, 2011 12:34
LGVector2D - A 2D Vector Class in C++
/*
* LGVector2D.cpp
*
* Created by Lee Grey on 11/06/11.
* Copyright 2011 Lee Grey. All rights reserved.
*
*/
#include "LGVector2D.h"
#include <iostream>
@leegrey
leegrey / Vector2D.as
Created June 22, 2011 08:43
LGVector2D.as - A 2D Vector Class in AS3
//CLASS: com.lgrey.vectors.LGVector2D
//created by Lee Grey
package com.lgrey.vectors {
import flash.geom.Point;
public class LGVector2D {
public var x:Number = 0;
public var y:Number = 0;
@leegrey
leegrey / TileWorld.as
Created November 11, 2011 10:15
TileWorld - Ray Casting in a Grid
// TileWorld.as - Lee Grey, November 2011
package com.lgrey.game.tileEngine
{
import com.lgrey.vectors.LGVector2D;
import flash.display.BitmapData;
public class TileWorld
{
protected var _worldMap:BitmapData;
@leegrey
leegrey / SeededRandomNumberGenerator.js
Created August 3, 2012 13:32
Seeded random in Javascript, translated from Michael Baczynski's AS2 ( http://www.polygonal.de )
/*
* Copyright (c) 2009 Michael Baczynski, http://www.polygonal.de
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@leegrey
leegrey / PerlinNoiseGenerator.js
Last active November 13, 2023 17:09
Seeded Perlin Noise in JavaScript - based on original by Ken Perlin
// Seeded Perlin Noise
//
// Based on the original by Ken Perlin:
//
// http://mrl.nyu.edu/~perlin/noise/
// http://mrl.nyu.edu/~perlin/paper445.pdf
//
// Seeding function based on code from:
// http://techcraft.codeplex.com/discussions/264014
//
@leegrey
leegrey / SignalHub.as
Created September 15, 2012 07:48
SignalHub.as is a Signal manager for AS3
/*
SignalHub:
Created on Sat 15th Sep, 2012
by Lee Grey
SignalHub solves the problem of object-creation order by using lazy initialisation - whoever
makes the first request for a Signal with a given key will bring about it's creation.
@leegrey
leegrey / inherit.js
Last active October 12, 2015 21:47
inherit.js - a minimal prototype inheritance utility
/*
Inherit copyright 2012 by Lee Grey
license: MIT
http://creativecommons.org/licenses/MIT/
http://opensource.org/licenses/mit-license.php
The goal of the Interit class is to allow for a prototype based inheritance that
does not create a deep prototype chain. Inherited fields are known to be slow,
so methods and fields are simply copied onto the prototype of the target,
keeping only a single depth.
@leegrey
leegrey / test.markdown
Last active December 14, 2015 21:29
Test
SECOND FILE
# H1
followed by some text
## H2
followed by some text
### H3
followed by some text
@leegrey
leegrey / InheritMax.js
Created July 17, 2013 04:25
InheritMax.js is a more advanced version of Inherit.js. It produces classes that contain a self calling init() function. I now prefer the simpler, stripped back functionality of Inherit.js, but have posted this for reference.
/*
Author: Lee Grey, 2012
License: MIT
USAGE:
var A = InheritMax.base( {
name: 'A',
say: function () {
console.log( 'A speaks' );
@leegrey
leegrey / TileMapPathField.ts
Last active May 4, 2020 12:52
Pathfinding on a Grid with Flow Fields
// Copyright Lee Grey, 2014
// License: MIT
module lg.tileSystem {
import Vector2D = lg.math.geometry.Vector2D;
export class FieldInfo {
distanceFromTarget: number = -1;