Skip to content

Commit 9454261

Browse files
committed
Better Cell formatting
1 parent fc2f4bf commit 9454261

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

src/components/Algorithms/Display.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function Display() {
2424
const [selectedStartPoint, setSelectedStartPoint] = useState(null);
2525
// const board = new Array(10000).fill(0).map(
2626
const board = new Array(3844).fill(0).map(
27-
(i, id, type: String = '_floor_', visited: Boolean = false) => ({id, type, visited}));
27+
(i, id, type: String = '_floor_', visited: Boolean = false, x: Number, y: Number ) => ({id, type, visited}));
2828

2929
const boardRef = useRef(); // Mutable(Persistant) board reference object.
3030

src/components/Algorithms/Maze/Generation/BinaryTreeCreation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {_FindCellVisitState, _FindCellTypeState, _FindCell} from './Tools';
66

77
export function BinaryTreeCreation(board) {
88
for (var i = 0; i < board.length; i++) {
9-
let direction = Math.floor(Math.random() * 4);
9+
let direction = Math.random() * 4;
1010
// console.log(board[i]);
1111

1212
// console.log(direction);

src/components/BoardCanvas/Cells.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,6 @@ const Cells = ({board, layoutType, mazeType, selectedPoint, onSelectPoint /*, u
248248
args = {[colorArray, 3]}
249249
/>
250250
</boxBufferGeometry>
251-
{/* <meshStandardMaterial */}
252-
{/* attach = "material" */}
253-
{/* color = "black" */}
254-
{/* wireframe */}
255-
{/* wireframeLinewidth={5} */}
256-
{/* wireframeLineheight={5} */}
257-
{/* // wireframeLinedepth={1} */}
258-
{/* /> */}
259251
<meshStandardMaterial
260252
attach = "material"
261253
vertexColors = {THREE.VertexColors}

src/components/BoardCanvas/layouts.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {useEffect, useRef, useState} from 'react';
33
import {useSpring} from 'react-spring/three';
44
import {BinaryTreeCreation} from '../Algorithms/Maze/Generation/BinaryTreeCreation';
55
import board from './Board';
6+
import {directions} from '../Algorithms/Maze/Generation/Directions';
67

78

89

@@ -180,6 +181,10 @@ function BinaryTreeMaze(board) {
180181

181182
for (let i = 0; i < numPoints; ++i) {
182183
const node = board[i];
184+
let direction = Math.random() * 4;
185+
186+
let xcord = board[i].x + directions[direction].x;
187+
let ycord = board[i].y + directions[direction].y;
183188
const col = (i % numCols) - numCols / 2;
184189
const row = Math.floor(i / numCols) - numCols / 2;
185190

0 commit comments

Comments
 (0)