mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 11:29:46 +02:00
SpawnAssistant hinzugefügt.
Sucht zufällig ein Path Tile zum spawnen für Spieler/Gegner/PowerUps.
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
package de.heatup.mapengine;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import de.heatup.cfg.Config;
|
||||||
|
|
||||||
|
public class SpawnAssistant {
|
||||||
|
public static Point getPathLocationOnGrid() {
|
||||||
|
Point spawnPoint = null;
|
||||||
|
Random rand = new Random();
|
||||||
|
boolean foundLocation = false;
|
||||||
|
while (!foundLocation) {
|
||||||
|
int x = rand.nextInt(Config.mapMaxTilesWidth);
|
||||||
|
int y = rand.nextInt(Config.mapMaxTilesHeight);
|
||||||
|
if (MapGrid.getGridCell(x, y).isPath()) {
|
||||||
|
spawnPoint = new Point(x,y);
|
||||||
|
foundLocation = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return spawnPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user