|
| 1 | +import { useState } from "react"; |
| 2 | +import Plane from "./Plane"; |
| 3 | +import List from "./List"; |
| 4 | + |
| 5 | +const coordinate = (x, y) => { |
| 6 | + const [select, setSelect] = useState(false); |
| 7 | + return { x, y, select, setSelect }; |
| 8 | +}; |
| 9 | + |
| 10 | +const Simulator = () => { |
| 11 | + const coordinates = []; |
| 12 | + for (let x = -1000; x <= 1000; x += 50) { |
| 13 | + for (let y = -1000; y <= 1000; y += 50) { |
| 14 | + if (x * x + y * y >= 1000 * 1000 || (x === 0 && y === 0)) continue; |
| 15 | + coordinates.push(coordinate(x, y)); |
| 16 | + } |
| 17 | + } |
| 18 | + |
| 19 | + const [duration, setDuration] = useState(20); |
| 20 | + const [speed, setSpeed] = useState(10); |
| 21 | + |
| 22 | + const simulate = () => { |
| 23 | + console.log("Simulation started"); |
| 24 | + }; |
| 25 | + |
| 26 | + return ( |
| 27 | + <div className="h-full w-full p-5 flex justify-center space-x-10"> |
| 28 | + <Plane coordinates={coordinates} /> |
| 29 | + <List coordinates={coordinates} /> |
| 30 | + <div className="flex flex-col space-y-5"> |
| 31 | + <div className="border flex"> |
| 32 | + <div className="bg-gray-200 py-3 w-[130px] text-center"> |
| 33 | + Duration {"(min)"} |
| 34 | + </div> |
| 35 | + <input |
| 36 | + type="number" |
| 37 | + className="w-[80px] text-center bg-gray-50 outline-none" |
| 38 | + value={duration} |
| 39 | + onChange={(e) => setDuration(e.target.value)} |
| 40 | + /> |
| 41 | + </div> |
| 42 | + <div className="border flex"> |
| 43 | + <div className="bg-gray-200 py-3 w-[130px] text-center"> |
| 44 | + Speed {"(m/s)"} |
| 45 | + </div> |
| 46 | + <input |
| 47 | + type="number" |
| 48 | + className="w-[80px] text-center bg-gray-50 outline-none" |
| 49 | + value={speed} |
| 50 | + onChange={(e) => setSpeed(e.target.value)} |
| 51 | + /> |
| 52 | + </div> |
| 53 | + <button |
| 54 | + className="bg-blue-500 text-white px-5 py-2 rounded-md" |
| 55 | + onClick={simulate} |
| 56 | + > |
| 57 | + Simulate |
| 58 | + </button> |
| 59 | + </div> |
| 60 | + </div> |
| 61 | + ); |
| 62 | +}; |
| 63 | + |
| 64 | +export default Simulator; |
0 commit comments