From 0894b83fabbff08456a3773051c61ee849cbdfa2 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 15 Nov 2018 10:29:05 -0500 Subject: [PATCH] randomize map on creation --- raycast.html | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/raycast.html b/raycast.html index 6330e62..90c3782 100644 --- a/raycast.html +++ b/raycast.html @@ -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); -- 2.55.0