Added basic draw function for list of rooms
This commit is contained in:
parent
8b7f83a14a
commit
77661df39b
@ -1,27 +1,21 @@
|
|||||||
import { RoomT } from "../types/room";
|
import { useRoomContext } from "../context";
|
||||||
import { Canvas } from "./Canvas";
|
import { Canvas } from "./Canvas";
|
||||||
|
|
||||||
export type BuildingPlanProps = { width: number; height: number };
|
export type BuildingPlanProps = { width: number; height: number };
|
||||||
|
|
||||||
export const BuildingPlan = ({ width, height }: BuildingPlanProps) => {
|
export const BuildingPlan = ({ width, height }: BuildingPlanProps) => {
|
||||||
const room: RoomT = {
|
const { state } = useRoomContext();
|
||||||
coordinates: { x: 100, y: 200 },
|
|
||||||
free: true,
|
|
||||||
size: { h: 100, w: 200 },
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Canvas
|
<Canvas
|
||||||
height={height}
|
height={height}
|
||||||
width={width}
|
width={width}
|
||||||
draw={(ctx) => {
|
draw={(ctx) => {
|
||||||
ctx.fillStyle = room.free ? "green" : "gray";
|
state.map.map(({ coordinates, size }, index) => {
|
||||||
ctx.fillRect(
|
const { free } = state.char[index];
|
||||||
room.coordinates.x,
|
ctx.fillStyle = free ? "green" : "gray";
|
||||||
room.coordinates.y,
|
ctx.fillRect(coordinates.x, coordinates.y, size.w, size.h);
|
||||||
room.size.w,
|
});
|
||||||
room.size.h
|
|
||||||
);
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user