diff --git a/src/lib/classes/managers/LocationManager.ts b/src/lib/classes/managers/LocationManager.ts index a766a4e..7a26265 100644 --- a/src/lib/classes/managers/LocationManager.ts +++ b/src/lib/classes/managers/LocationManager.ts @@ -10,6 +10,10 @@ export type Galaxy = { _id: ObjectId, name: string, sectors: Array + coords: { + x: number, + y: number + } } export type Sector = { @@ -56,7 +60,8 @@ class LocationManager { const galaxyObject: Galaxy = { _id: galaxy._id, name: galaxy.name, - sectors: [] + sectors: [], + coords: galaxy.coords }; for(const sectorId of galaxy.sectors) { diff --git a/src/pages/game/galaxyView.astro b/src/pages/game/galaxyView.astro index 4b2ede8..13ca768 100644 --- a/src/pages/game/galaxyView.astro +++ b/src/pages/game/galaxyView.astro @@ -20,9 +20,9 @@ const galaxies = allGalaxies.map(galaxy => { numericId: i++, name: galaxy.name, style: { - left: 0, - top: 0, - color: "red" + left: galaxy.coords.x, + top: galaxy.coords.y, + color: "white" }, sectors: galaxy.sectors.map(sector => { return { @@ -32,23 +32,6 @@ const galaxies = allGalaxies.map(galaxy => { }) }; }) - -for(const galaxy of galaxies) { - for(let i = 0; i < 100; i++) { - galaxy.style.left = Math.random() * 1200 + 20; - galaxy.style.top = Math.random() * 380 + 20; - const overlap = galaxies.slice(0, galaxy.numericId).some(otherGalaxy => { - const dx = galaxy.style.left - otherGalaxy.style.left; - const dy = galaxy.style.top - otherGalaxy.style.top; - const distance = Math.sqrt(dx * dx + dy * dy); - return distance < 100; - }); - if(!overlap) { - galaxy.style.color = "white" - break; - } - } -} --- diff --git a/src/types/db/DBGalaxy.ts b/src/types/db/DBGalaxy.ts index 74fe2a5..092d095 100644 --- a/src/types/db/DBGalaxy.ts +++ b/src/types/db/DBGalaxy.ts @@ -4,4 +4,8 @@ export default interface DBGalaxy { _id: ObjectId; name: string; sectors: Array; + coords: { + x: number; + y: number; + } } \ No newline at end of file