- http://pypi.python.org/pypi/jsongrep
- list of tools at https://github.com/trentm/json#readme
- json:select: http://jsonselect.org/
- jsonpipe: https://github.com/dvxhouse/jsonpipe
- json-command: https://github.com/zpoley/json-command
- JSONPath: http://goessner.net/articles/JsonPath/, http://code.google.com/p/jsonpath/wiki/Javascript
- http://stedolan.github.io/jq/
- jsawk: https://github.com/micha/jsawk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var NUM_SPRITE_COLS = 6; | |
var gm = require('gm'); | |
grunt.registerMultiTask('sprite', 'Sprite images', function() { | |
var images = this.data; | |
var numRows = Math.ceil(images.length / NUM_SPRITE_COLS); | |
var sprite = gm(''); | |
sprite.tile(NUM_SPRITE_COLS + 'x' + numRows); | |
sprite.quality('100'); | |
sprite.background('transparent'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sprite: { | |
'media/player.png': [ | |
'build/player-idle001.png', | |
'build/player-kneel001.png', | |
'build/player-kneel002.png', | |
'build/player-kneel003.png', | |
'build/player-kneel004.png', | |
'build/player-kneel005.png', | |
'build/player-walk001.png', | |
'build/player-walk002.png', |
I have a lot of classes extending Phaser.Sprite
. Building each one by hand via some if
statement when loading a tilemap is dumb. Thankfully, webpack is here to rescue me.
The full code of entityFactory.js
is below.
Say you've got a directory full of sprites, each one a subclass of Phaser.Sprite
:
Make a second canvas, hide the initial Phaser canvas, draw a scaled version of the first canvas onto the second.
From this post: http://www.photonstorm.com/phaser/pixel-perfect-scaling-a-phaser-game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var idableLayers = ['entities', 'switches'] | |
module.exports = function(content) { | |
this.cacheable && this.cacheable(); | |
var map = JSON.parse(content); | |
var pathBits = this.resourcePath.split('/'); | |
var mapFilename = pathBits[pathBits.length - 1]; | |
if (map.layers) { | |
map.layers.forEach(function(layer) { | |
if (idableLayers.indexOf(layer.name) === -1 ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sha1(str) { | |
function hex(buffer) { | |
const hexCodes = []; | |
const view = new DataView(buffer); | |
for (let i = 0; i < view.byteLength; i += 4) { | |
// Using getUint32 reduces the number of iterations needed (we process 4 bytes each time) | |
const value = view.getUint32(i) | |
// toString(16) will give the hex representation of the number without padding | |
const stringValue = value.toString(16) | |
// We use concatenation and slice for padding. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here they are! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const size = 48; | |
const maxFrames = 6; | |
const blastRadius = 23; | |
export default class Shockwave extends Phaser.Plugin { | |
constructor(game, parent) { | |
super(game, parent); | |
this.firing = false; | |
this.x = this.y = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import forsaken from '../forsaken'; | |
export const FACTORY = (game, mapEntity) => { | |
const { x, y, width, height, properties: { id, reversible = true } } = mapEntity; | |
return new StoneSmasher(game, id, x, y, width, height, reversible); | |
} | |
export const GROUP_NAME = 'obstacles'; | |
const frame = i => `stoneSmasher${i}`; |