Skip to content

Instantly share code, notes, and snippets.

Avatar

Geoff Blair geoffb

View GitHub Profile
View pixi-spritebatch-mask.js
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);
View gist:303132
var myObject = function (someParam) {
var privateMember = "foobar";
return {
publicMethod: function () {
return "Hi! " + someParam + " " + privateMember;
}
};
View example.sql
-- I used to do it like this:
SELECT * FROM table WHERE
hurr
AND (foo = 'bar')
AND (bar = 'foo')
-- Then later I spaced it out even more:
SELECT
@geoffb
geoffb / canvas_perf_demo.html
Created Jun 2, 2010
Canvas Performance Demo
View canvas_perf_demo.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Canvas Performance Demo</title>
</head>
<body>
<div>
<h1>Canvas Performance Test</h1>
@geoffb
geoffb / libtiled.pro.diff
Created Jun 29, 2010
Patch to allow Tiled 0.5.0+ to compile under OSX
View libtiled.pro.diff
diff --git a/src/libtiled/libtiled.pro b/src/libtiled/libtiled.pro
index bd24e9c..5438f80 100644
--- a/src/libtiled/libtiled.pro
+++ b/src/libtiled/libtiled.pro
@@ -31,3 +31,8 @@ mac {
ppc
QMAKE_MAC_SDK = /Developer/SDKs/MacOSX10.5.sdk
}
+
+macx {
View gist:500856
if (
something &&
!somethingElse &&
otherThing === null) {
callFunction();
}
@geoffb
geoffb / Sprite Alpha using Canvas
Created Aug 14, 2010
A simple example of changing the alpha of a sprite.
View Sprite Alpha using Canvas
ctx.save();
// 50% opacity
// Anything drawn after this call (but before call .restore) will be drawn at 50% opacity
ctx.globalAlpha = 0.5;
ctx.drawImage(
spriteSourceImage,
sourceX, sourceY, sourceWidth, sourceHeight,
destX, destY, destWidth, destHeight
@geoffb
geoffb / wtf.js
Created Nov 6, 2010
Fucking around
View wtf.js
(function () {
// Extends the base Object with data getter/setter and event target
var proto = Object.prototype;
proto._data = {};
proto._listeners = {};
proto.set = function (key, value) {
@geoffb
geoffb / impact_suspend.js
Created Jan 12, 2011
ImpactJS: Suspend/Resume on blur/focus
View impact_suspend.js
window.addEventListener("blur", function () {
if (ig.system) {
ig.music.stop();
ig.system.stopRunLoop();
}
}, false);
window.addEventListener("focus", function () {
if (ig.system) {
ig.music.play();
@geoffb
geoffb / astar.js
Created Jan 12, 2011
Simple A* Pathfinding
View astar.js
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;
You can’t perform that action at this time.