This file contains hidden or 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', |
This file contains hidden or 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 hidden or 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
| # | |
| # Shamelessly copied from http://blog.yesmeck.com/archives/make-git-automatically-remove-trailing-whitespace-before-committing/ | |
| # | |
| # What's distinct about this version, as opposed to several I've seen, | |
| # is that it only fixes the whitespace on lines you've actually changed, | |
| # so avoids making you the blamee of code you didn't change. | |
| # Find files with trailing whitespace | |
| for file in `git diff --check --cached | grep '^[^+-]' | grep -o '^.*[0-9]\+:'` ; do | |
| file_name=`echo ${file} | grep -o '^[^:]\+'` |
This file contains hidden or 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
| update.repeat = function(times) { | |
| times = times || Infinity; | |
| var originalTimes = times; | |
| var stepsCopy; | |
| steps.push(function() { | |
| times -= 1; | |
| if (times > 0) { | |
| var args = stepsCopy.slice(0); | |
| args.unshift(1, 0); | |
| [].splice.apply(steps, args); |
This file contains hidden or 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
| // Returned from this constructor thing. | |
| return update; | |
| }; | |
| }); |
This file contains hidden or 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
| update.every = function(sec, doThis) { | |
| update.during( | |
| new EventChain() | |
| .wait(sec) | |
| .then(doThis) | |
| .repeat() | |
| ); | |
| return this; | |
| }; |
This file contains hidden or 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
| update.during = function(doThis) { | |
| if (!steps) { | |
| throw new Error('during only works with previous step!'); | |
| } | |
| var func = steps[steps.length - 1]; | |
| steps[steps.length - 1] = function() { | |
| doThis(); | |
| func(); | |
| }; | |
| return this; |
This file contains hidden or 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
| update.wait = function(secs) { | |
| var decrement = secs; | |
| steps.push(function() { | |
| // Update. | |
| if (decrement) { | |
| decrement -= ig.system.tick; | |
| } | |
| // End. | |
| if (decrement <= 0) { | |
| steps.shift(); |
This file contains hidden or 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
| update.then = function(doThis) { | |
| steps.push(function() { | |
| // Update. | |
| doThis(); | |
| // End. | |
| steps.shift(); | |
| }); | |
| return this; | |
| } |
This file contains hidden or 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
| // Defines a function that can fire sequential events. | |
| EventChain = function() { | |
| // Make sure we get called with new. | |
| if (this === window) { | |
| return new EventChain(); | |
| } | |
| var steps = []; | |
| // Called every frame. |