23 lines
596 B
TypeScript
23 lines
596 B
TypeScript
import Cell from "./Cell.tsx";
|
|
|
|
|
|
export default function Maze({state, dispatch}) {
|
|
if (!state.maze) {
|
|
return <div>No valid maze.</div>
|
|
}
|
|
|
|
let maze: JSX.Element[] = [];
|
|
for (let y = 0; y < state.maze.height; y++) {
|
|
let row: JSX.Element[] = [];
|
|
for (let x = 0; x < state.maze.width; x++) {
|
|
row.push(<Cell key={`${x}x${y}`} x={x} y={y} state={state} dispatch={dispatch}/>)
|
|
}
|
|
maze.push(<div key={`r${y}`} className={"row"}>{row}</div>);
|
|
}
|
|
return (
|
|
<div className={"maze"}>
|
|
{maze}
|
|
</div>
|
|
);
|
|
}
|