From: Michael D. Lowis Date: Thu, 15 Nov 2018 15:29:05 +0000 (-0500) Subject: randomize map on creation X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=0894b83fabbff08456a3773051c61ee849cbdfa2;p=proto%2Fjstoys.git randomize map on creation --- 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);