Advertisement
rAthus

Javascript : do a barrel roll en Konami Code

Feb 27th, 2014
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. doabarrelroll = function()
  2. {
  3.     if (typeof(barrelrolls)=='undefined')
  4.         barrelrolls = 0;
  5.     barrelrolls++;
  6.     var head = document.getElementsByTagName('head')[0];
  7.     var style = document.createElement('style');
  8.     var declarations = document.createTextNode('body { transform:rotate('+degBarrelRoll*barrelrolls+'deg); -ms-transform:rotate('+degBarrelRoll*barrelrolls+'deg); -moz-transform:rotate('+degBarrelRoll*barrelrolls+'deg); -webkit-transform:rotate('+degBarrelRoll*barrelrolls+'deg); -o-transform:rotate('+degBarrelRoll*barrelrolls+'deg); transition: '+secBarrellRoll+'s; -moz-transition: '+secBarrellRoll+'s; -webkit-transition: '+secBarrellRoll+'s; -o-transition: '+secBarrellRoll+'s; }');
  9.     style.type = 'text/css';
  10.     if (style.styleSheet)
  11.         style.styleSheet.cssText = declarations.nodeValue;
  12.     else
  13.         style.appendChild(declarations);
  14.     head.appendChild(style);
  15. }
  16. var kKeys = '';
  17. $(document).keydown(function(e)
  18. {
  19.     kKeys = (kKeys+e.keyCode+',').slice(-30);
  20.     if (kKeys.indexOf('38,38,40,40,37,39,37,39,66,65')>-1)
  21.     {
  22.         doabarrelroll();
  23.         kKeys = '';
  24.     }
  25. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement