Advertisement
zopper

XKCD 1110 Cinematic mode

Sep 19th, 2012
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* This is "cinematic mode" for XKCD 1110 ( http://xkcd.com/1110/ )
  2.     Author: Jan "Zopper" Tulak
  3.     You can do with this whatever you want. Even destroy the world.
  4. */
  5.  
  6. /* USAGE:
  7.     paste it into the JS console (in Google Chrome: ctrl+shift+c, then select "console")
  8.  
  9.    CONTROL:
  10.     W - up, S - down, A - left, D - right
  11. */
  12.  
  13. $("#comic img")[0].style.display="none"
  14. $("body")[0].style.marginLeft=0;
  15. $("body")[0].style.backgroundColor="#fff";
  16. $("body")[0].style.left=0;
  17. $("#middleContainer")[0].style.marginLeft=0;
  18. $("#middleContainer")[0].style.border=0;
  19. $("#middleContainer")[0].style.position="absolute";
  20. $("#middleContainer")[0].style.left="0px";
  21. $("#middleContainer")[0].style.top="-100px";
  22.  
  23. function setSize(){
  24.     $("#comic")[0].style.width=($(window).width()-2)+"px";
  25.     $("#comic")[0].style.height=($(window).height()-5)+"px";
  26. }
  27. setSize();
  28.  
  29. $(window).resize(function() {
  30.   setSize();
  31. });
  32.  
  33. function move() {
  34.     guu=$(".map")[0];
  35.  
  36.     this.left=function (){  guu.style.left=(guu.style.left.replace("px","")*1+100)+"px"; };
  37.     this.right=function (){ guu.style.left=(guu.style.left.replace("px","")*1-100)+"px"; };
  38.     this.top=function (){   guu.style.top=(guu.style.top.replace("px","")*1+100)+"px"; };
  39.     this.down=function (){  guu.style.top=(guu.style.top.replace("px","")*1-100)+"px"; };
  40. }
  41.  
  42. mv=new move();
  43. $("body").keypress(function(key){
  44.     if(key.keyCode == 119) {
  45.         mv.top();
  46.     }else if(key.keyCode == 115) {
  47.         mv.down();
  48.     }else if(key.keyCode == 100) {
  49.         mv.right();
  50.     }else if(key.keyCode == 97) {
  51.         mv.left();
  52.     }
  53.  
  54. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement