Skip to content

Instantly share code, notes, and snippets.

@taf2
Forked from jcbozonier/gist:1195233
Created September 5, 2011 18:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save taf2/1195667 to your computer and use it in GitHub Desktop.
Save taf2/1195667 to your computer and use it in GitHub Desktop.
// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.com/#x15.4.4.18
if (!Array.prototype.forEach) {
Array.prototype.forEach = function( callback, thisArg ) {
var T, k;
if ( this == null ) {
throw new TypeError( " this is null or not defined" );
}
var O = Object(this);
var len = O.length >>> 0;
if ( {}.toString.call(callback) != "[object Function]" ) {
throw new TypeError( callback + " is not a function" );
}
if ( thisArg ) { T = thisArg; }
k = 0;
while( k < len ) {
var kValue;
if ( k in O ) {
kValue = O[Pk];
callback.call( T, kValue, k, O );
}
k++;
}
};
}
document.onkeydown = function(event) {
var game_piece, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _n;
switch (event.keyCode) {
case 37:
game_pieces.forEach(function(game_piece) { game_piece.pan_left() });
break;
case 38:
game_pieces.forEach(function(game_piece) { game_piece.pan_up() });
break;
case 39:
game_pieces.forEach(function(game_piece) { game_piece.pan_right() });
break;
case 40:
game_pieces.forEach(function(game_piece) { game_piece.pan_down() });
break;
case 189:
game_pieces.forEach(function(game_piece) { game_piece.zoom_out() });
break;
case 187:
game_pieces.forEach(function(game_piece) { game_piece.zoom_in() });
}
return the_screen.refresh(game_pieces);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment