]> git.mdlowis.com Git - proto/jstoys.git/commitdiff
randomize map on creation
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 15 Nov 2018 15:29:05 +0000 (10:29 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 15 Nov 2018 15:29:05 +0000 (10:29 -0500)
raycast.html

index 6330e6283e0a2f8bf40e0ee0ac40ba8f02813bd4..90c3782b18d7298e331ce81c6ba470bdd681cab1 100644 (file)
@@ -64,10 +64,8 @@ const Player = ((self = START_POS)=>{
 })();
 
 const Map = ((grid = new Uint8Array(MAP_SIZE ** 2))=>{
-    return {
-        get: (x, y)=>(grid[Math.floor(y) * MAP_SIZE + Math.floor(x)] || -1),
-        randomize: ()=>(grid = grid.map((i) => (Math.random() < 0.3 ? 1 : 0))),
-    };
+    grid = grid.map((i) => (Math.random() < 0.3 ? 1 : 0));
+    return { get: (x, y)=>(grid[Math.floor(y) * MAP_SIZE + Math.floor(x)] || -1) };
 })();
 
 const Camera = ((self = {}, columns = [], ceiling = null, floor = null)=>{
@@ -168,7 +166,6 @@ const Camera = ((self = {}, columns = [], ceiling = null, floor = null)=>{
 })();
 
 (() => {
-    Map.randomize();
     const loop = (now) => {
         const seconds = FrameTimer.update(now);
         Player.update(seconds);