From e6d1d9c9dd9e807ee9f6f7a806d526886fbdc2bd Mon Sep 17 00:00:00 2001 From: "theo@manjaro" Date: Mon, 13 Sep 2021 10:53:42 +0200 Subject: [PATCH] Updated tererain generation --- gamedata/objects/ingame/tiles.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gamedata/objects/ingame/tiles.py b/gamedata/objects/ingame/tiles.py index 0afb00d..51591e7 100644 --- a/gamedata/objects/ingame/tiles.py +++ b/gamedata/objects/ingame/tiles.py @@ -13,18 +13,20 @@ class Tiles(BaseObject): self.nbcells = nbcells self.cellsize = cellsize - self.grid = self.gengrid(nbcells,nbcells) - self.spawns = self.getspawnpoints(self.grid) + self.saferadius = 2 - def gengrid(self,w,h): + self.grid = self.gengrid(nbcells,nbcells,minsize=self.saferadius*2+1) + self.spawns = self.getspawnpoints(self.grid,saferadius=self.saferadius) + + def gengrid(self,w,h,minsize=3,randrange=4): # Generating various rectangles on a map grid = [ [0 for x in range(w)] for y in range(h) ] nb_rects = int(sqrt(w*h)/1.5+0.5) for i in range(nb_rects): # Generating the rects - rectw = random.randint(3,7) - recth = random.randint(3,7) + rectw = random.randint(0,randrange)+minsize + recth = random.randint(0,randrange)+minsize rectx = random.randint(0,w-rectw) recty = random.randint(0,h-recth)