addEventListener("keydown", function(e) { if(e.keyCode == 32) { // espace tx = Math.round(G.game.player.x / G.basesize); ty = Math.round(G.game.player.y / G.basesize); map = G.map.big_world; switch(G.game.player.dir) { case "up": map.map[tx][ty-1] = 2; map.map_t[tx][ty-1] = 0; break; case "down": map.map_t[tx][ty+1] = 0; map.map[tx][ty+1] = 2; break; case "left": map.map_t[tx-1][ty] = 0; map.map[tx-1][ty] = 2; break; case "right": map.map_t[tx+1][ty] = 0; map.map[tx+1][ty] = 2; break; } } });