Skip to content

Instantly share code, notes, and snippets.

@drhayes
drhayes / buildNative.js
Last active Aug 28, 2015
The file that builds my game using nw.js.
View buildNative.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 Mar 12, 2014
How I'm scaling my 2d Phaser game right now
View gist:9513977
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();
View 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:

View gist:efcc999154ce2c256a35
Verifying myself: My Bitcoin username is +drhayes. https://onename.io/drhayes
@drhayes
drhayes / bezier.js
Created Jan 5, 2015
bezier curve functions for ImpactJS.
View bezier.js
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 Oct 22, 2012
ImpactJS syntax definition
View ImpactJS.JSON-tmLanguage
{ "name": "ImpactJS", "scopeName": "source.js.impact",
"fileTypes": ["js"],
"patterns": [
{
"name": "meta.module.impact",
"begin": "\\b(ig)\\.(module)\\(",
"beginCaptures": {
"1": {
"name": "support.variable.impact.namespace"
},
View 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 Nov 15, 2012
Part of an ImpactJS library to change how entities act at runtime.
View enableBehaviors.js
ig.module(
'game.behaviors.enableBehaviors'
)
.requires(
'impact.impact'
)
.defines(function() {
enableBehaviors = function(entityClass) {
entityClass.inject({
@drhayes
drhayes / baseBehavior.js
Created Nov 15, 2012
Base class for behaviors.
View baseBehavior.js
ig.module(
'game.behaviors.baseBehavior'
)
.requires(
'impact.impact'
)
.defines(function() {
BaseBehavior = ig.Class.extend({
enabled: true,
@drhayes
drhayes / player.js
Created Nov 15, 2012
Snippet from the player entity.
View player.js
update: function() {
this.behave('update');
this.handleAnimation();
this.parent();
},
handleMovementTrace: function(res) {
this.behave('handleMovementTrace', res);
this.parent(res);
},