Skip to content

Instantly share code, notes, and snippets.

View drhayes's full-sized avatar
🐱

David Hayes drhayes

🐱
View GitHub Profile
@drhayes
drhayes / buildNative.js
Last active August 28, 2015 19:44
The file that builds my game using nw.js.
// Are you running me from "npm run build-native"? 'Cuz you should.
// Tips:
// * Copy what this guy did: https://github.com/octalmage/Marknote for icons
// and stuff.
// * Turn on devtools by changing "window.toolbar" in package.json to true.
var NwBuilder = require('nw-builder');
var nw = new NwBuilder({
files: [
@drhayes
drhayes / gist:9513977
Created March 12, 2014 19:04
How I'm scaling my 2d Phaser game right now
preload: function() {
game.stage.scale.minWidth = 320;
game.stage.scale.minHeight = 240;
game.stage.scale.maxWidth = 640;
game.stage.scale.maxHeight = 480;
game.stage.scale.pageAlignHorizontally = true;
game.stage.scale.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
game.stage.scale.setShowAll();
@drhayes
drhayes / keybase.md
Created June 12, 2014 21:21
keybase.md

Keybase proof

I hereby claim:

  • I am drhayes on github.
  • I am drhayes (https://keybase.io/drhayes) on keybase.
  • I have a public key whose fingerprint is 17C5 BB89 6584 45B1 B431 D800 78E4 6D79 D295 413E

To claim this, I am signing this object:

@drhayes
drhayes / gist:efcc999154ce2c256a35
Created July 23, 2014 21:32
onename verification
Verifying myself: My Bitcoin username is +drhayes. https://onename.io/drhayes
@drhayes
drhayes / bezier.js
Created January 5, 2015 16:37
bezier curve functions for ImpactJS.
ig.module(
'game.util.bezier'
)
.defines(function() {
'use strict';
// With the help of: http://www.moshplant.com/direct-or/bezier/math.html
// Code totally stolen from processing.js.
// 0 <= t <= 1
@drhayes
drhayes / ImpactJS.JSON-tmLanguage
Created October 22, 2012 06:32
ImpactJS syntax definition
{ "name": "ImpactJS", "scopeName": "source.js.impact",
"fileTypes": ["js"],
"patterns": [
{
"name": "meta.module.impact",
"begin": "\\b(ig)\\.(module)\\(",
"beginCaptures": {
"1": {
"name": "support.variable.impact.namespace"
},
@drhayes
drhayes / followCamera.js
Created October 28, 2012 22:23
followCamera.js
calculatePlayerStats: function() {
this.player = ig.game.getEntityByName('player');
// Did we actually get a player?
if (this.player) {
// Cache some stats.
this.halfPlayerWidth = this.player.size.x / 2;
this.halfPlayerHeight = this.player.size.y / 2;
this.maxVel = this.player.maxVel;
}
},
@drhayes
drhayes / enableBehaviors.js
Created November 15, 2012 04:43
Part of an ImpactJS library to change how entities act at runtime.
ig.module(
'game.behaviors.enableBehaviors'
)
.requires(
'impact.impact'
)
.defines(function() {
enableBehaviors = function(entityClass) {
entityClass.inject({
@drhayes
drhayes / baseBehavior.js
Created November 15, 2012 04:46
Base class for behaviors.
ig.module(
'game.behaviors.baseBehavior'
)
.requires(
'impact.impact'
)
.defines(function() {
BaseBehavior = ig.Class.extend({
enabled: true,
@drhayes
drhayes / player.js
Created November 15, 2012 04:48
Snippet from the player entity.
update: function() {
this.behave('update');
this.handleAnimation();
this.parent();
},
handleMovementTrace: function(res) {
this.behave('handleMovementTrace', res);
this.parent(res);
},