Updated tererain generation
This commit is contained in:
parent
70b1f0760d
commit
e6d1d9c9dd
@ -13,18 +13,20 @@ class Tiles(BaseObject):
|
|||||||
self.nbcells = nbcells
|
self.nbcells = nbcells
|
||||||
self.cellsize = cellsize
|
self.cellsize = cellsize
|
||||||
|
|
||||||
self.grid = self.gengrid(nbcells,nbcells)
|
self.saferadius = 2
|
||||||
self.spawns = self.getspawnpoints(self.grid)
|
|
||||||
|
|
||||||
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
|
# Generating various rectangles on a map
|
||||||
grid = [ [0 for x in range(w)] for y in range(h) ]
|
grid = [ [0 for x in range(w)] for y in range(h) ]
|
||||||
nb_rects = int(sqrt(w*h)/1.5+0.5)
|
nb_rects = int(sqrt(w*h)/1.5+0.5)
|
||||||
|
|
||||||
for i in range(nb_rects):
|
for i in range(nb_rects):
|
||||||
# Generating the rects
|
# Generating the rects
|
||||||
rectw = random.randint(3,7)
|
rectw = random.randint(0,randrange)+minsize
|
||||||
recth = random.randint(3,7)
|
recth = random.randint(0,randrange)+minsize
|
||||||
rectx = random.randint(0,w-rectw)
|
rectx = random.randint(0,w-rectw)
|
||||||
recty = random.randint(0,h-recth)
|
recty = random.randint(0,h-recth)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user