Răsfoiți Sursa

Add expansionRate value

This value allows the user to set the rate at which empty rows or
columns expand.
ApisNecros 1 an în urmă
părinte
comite
3155bde380
1 a modificat fișierele cu 5 adăugiri și 3 ștergeri
  1. 5 3
      11/11_common.ts

+ 5 - 3
11/11_common.ts

@@ -3,12 +3,14 @@ import { Vector2 } from "../3/3_common.ts";
 export class StarMap {
     private originalMap: string[];
     private mapDimensions: {width: number, height: number};
+    private expansionRate: number;
     public galaxyList: Array<Vector2> = [];
     public emptyColumns: number[] = [];
     public emptyRows: number[] = [];
 
-    constructor(rawMap: string[]) {
+    constructor(rawMap: string[], expansionRate = 1) {
         this.originalMap = rawMap;
+        this.expansionRate = expansionRate
         this.mapDimensions = {
             width: this.originalMap[0].length,
             height: this.originalMap.length
@@ -72,7 +74,7 @@ export class StarMap {
         let xOffset = 0;
         this.emptyColumns.forEach((col) => {
             if (between(col, galaxy1.X, galaxy2.X)) {
-                yOffset += 1;
+                yOffset += this.expansionRate;
                 if (debug) {
                     console.log(`Adding 2 for the empty column at ${col}`);
                 }
@@ -80,7 +82,7 @@ export class StarMap {
         });
         this.emptyRows.forEach((row) => {
             if (between(row, galaxy1.Y, galaxy2.Y)) {
-                xOffset += 1;
+                xOffset += this.expansionRate;
                 if (debug) {
                     console.log(`Adding 2 for the empty row at ${row}`);
                 }