Skip to content

Instantly share code, notes, and snippets.

View geoffb's full-sized avatar
🕹️
Making games!

Geoff Blair geoffb

🕹️
Making games!
View GitHub Profile
@geoffb
geoffb / astar.js
Created January 12, 2011 18:59
Simple A* Pathfinding
var AStar;
(function () {
var Node = function (index, x, y, parent) {
this.index = index;
this.x = x;
this.y = y;
this.parent = parent || null;
this.f = 0;
<!DOCTYPE html>
<html lang="en">
<head>
<title>jQuery Event Test</title>
<style>
.red {
background: #f00;
}
.blue {
background: #00f;
@geoffb
geoffb / animation.js.diff
Created February 16, 2011 18:46
Patch allowing Weltmeister to show the first frame of an entity's animation rather than the top left sprite in it's animation sheet.
diff --git a/lib/impact/animation.js b/lib/impact/animation.js
index 20839f9..f367083 100644
--- a/lib/impact/animation.js
+++ b/lib/impact/animation.js
@@ -45,6 +45,7 @@ ig.Animation = ig.Class.extend({
this.frameTime = frameTime;
this.sequence = sequence;
this.stop = !!stop;
+ this.tile = this.sequence[0];
},
@geoffb
geoffb / QBasic.tmTheme
Created September 8, 2011 21:19
TextMate QBasic Theme - Just for fun
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>QBasic</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<!DOCTYPE html>
<html>
<head>
<title>Canvas Path Fill test</title>
</head>
<body>
<canvas id="stage" width="256" height="256"></canvas>
<script>
@geoffb
geoffb / simple-canvas-rotation.html
Last active February 23, 2023 20:56
A simple example of rotating a rectangle using HTML5 canvas.
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Canvas Transformation</title>
</head>
<body>
<script>
// Create our canvas and append it to the document body
var stage = document.createElement("canvas");
var renderer = new PIXI.autoDetectRenderer(400, 400);
document.body.appendChild(renderer.view);
var stage = new PIXI.Stage(0x0000FF);
var container = new PIXI.DisplayObjectContainer();
stage.addChild(container);
var spriteBatch = new PIXI.SpriteBatch();
stage.addChild(spriteBatch);
@geoffb
geoffb / permut.js
Created February 24, 2017 03:59
Calculate permutations
var permut = function (array, count, initial, output) {
if (initial.length >= count) {
output.push(initial);
} else {
for (var i = 0; i < array.length; ++i) {
permut(array, count, initial.concat(array[i]), output);
}
}
};
@geoffb
geoffb / command-repl.js
Created December 20, 2017 20:53
Simple example of a command REPL in Node.js
const readline = require("readline");
let input = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let queryCommand = () => {
input.question("Command: ", (command) => {
if (command === "exit") {