SuperMonkey

Poke terraformeur

Apr 30th, 2014
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. addEventListener("keydown", function(e) {
  2.     if(e.keyCode == 32) { // espace
  3.         tx = Math.round(G.game.player.x / G.basesize);
  4.         ty = Math.round(G.game.player.y / G.basesize);
  5.        
  6.         map = G.map.big_world;
  7.        
  8.         switch(G.game.player.dir) {
  9.             case "up":
  10.                 map.map[tx][ty-1] = 2;
  11.                 map.map_t[tx][ty-1] = 0; break;
  12.             case "down":
  13.                 map.map_t[tx][ty+1] = 0;
  14.                 map.map[tx][ty+1] = 2; break;
  15.             case "left":
  16.                 map.map_t[tx-1][ty] = 0;
  17.                 map.map[tx-1][ty] = 2; break;
  18.             case "right":
  19.                 map.map_t[tx+1][ty] = 0;
  20.                 map.map[tx+1][ty] = 2; break;
  21.         }
  22.     }
  23. });
Advertisement
Add Comment
Please, Sign In to add comment