forked from ayte/PinmikPanik
Updated tererain generation
This commit is contained in:
parent
70b1f0760d
commit
e6d1d9c9dd
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user