Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var buffer = new ArrayBuffer(4 + 4 + Math.floor((maze.length * maze[0].length + 7) / 8) * 8);
- var view = new DataView(buffer);
- view.setUint32(0, maze.length);
- console.log(view.getUint32(0));
- view.setUint32(4, maze[0].length);
- console.log(view.getUint32(4));
- let tempint = 0;
- let ly = 0, lx = 0;
- for (ly = 0; ly < maze.length; ly += 1) {
- for (lx = 0; lx < maze[0].length; lx += 1) {
- if (maze[ly][lx] == '-1') {
- tempint = tempint | (128 >> ((ly * maze[0].length + lx) % 8));
- //console.log(1);
- }
- //else console.log(0);
- //console.log(tempint.toString(2));
- if ((ly * maze[0].length + lx) % 8 == 7) {
- //console.log("Tempint ", tempint.toString(2));
- view.setUint8(Math.floor((ly * maze[0].length + lx) / 8) + 8, tempint);
- console.log(view.getUint8(Math.floor((ly * maze[0].length + lx) / 8) + 8).toString(2));
- //console.log("NewString");
- tempint = 0;
- }
- }
RAW Paste Data