Skip to content

Instantly share code, notes, and snippets.

View justinbowes's full-sized avatar
💭
I may be slow to respond.

Justin Bowes justinbowes

💭
I may be slow to respond.
View GitHub Profile
@justinbowes
justinbowes / Game.cpp
Last active December 16, 2015 20:19
Making pighead10's SFML Ludum Dare entry, "You are the Minimalist", run in OSX.
// Call to implicitly-deleted copy constructor
Game.cpp:16 --------------------
-sf::RenderTexture Game::gameOutput = sf::RenderTexture();
+sf::RenderTexture Game::gameOutput;
@justinbowes
justinbowes / gist:3297745
Created August 8, 2012 19:11
JavaScript binary heap with merge support
var BinaryHeap = function BinaryHeap(scoreFunction, populate){
this.content = (populate ? populate.slice(0) : []);
this.scoreFunction = scoreFunction;
if (this.content.length) {
this.build();
}
}
BinaryHeap.prototype = {
// Implements an LCG RNG.
var Random = function Random(seed) {
this.term = (typeof seed !== 'undefined' ? seed : new Date().getTime());
this.multiplier = 60969; // carefully chosen
this.modulus = Math.pow(2, 32);
this.increment = 1;
};
Random.prototype.randInt = function(range) {
this.term = (this.term * this.multiplier + this.increment) % this.modulus;
@justinbowes
justinbowes / gist:2889905
Created June 7, 2012 16:32
chevyray's post translated from incomprehensible font
private function pushOutUnits(elastic:Number):void
{
for (var i:int = 0; i < units.length - 1; i++)
{
for (var j:int = i + 1; j < units.length; j++)
{
push.x = units[i].x - units[j].x;
push.y = units[i].y - units[j].y;
var d:number = push.length;