Пример #1
0
 def draw_walls(self):
     """
     Spawn walls and other obstacles and draw on window surface
     """
     BOXSIZE = self.window_width - 200
     WALLWIDTH = 50
     obsList = dispUtils.createWalls(self.windowSurface,BOXSIZE,WALLWIDTH)
     for shape in obsList:
         pygame.draw.polygon(self.windowSurface, [0,0,0], shape)
#Generate Map
map_data = dispUtils.mapGeneration(windowSurface,map_type)
windowSurface.fill(map_data[1])
dispUtils.drawObstacles(windowSurface, map_data[2], map_data[0])

# movement Parameters
forawardSpeed = {'linearSpeed': 50/updatesPerSecond, 'angularSpeed': 0/updatesPerSecond}
leftSpeed = {'linearSpeed': 0/updatesPerSecond, 'angularSpeed': -0.6/updatesPerSecond}
rightSpeed = {'linearSpeed': 0/updatesPerSecond, 'angularSpeed': 0.6/updatesPerSecond}
stopSpeed = {'linearSpeed': 0, 'angularSpeed': 0}

# spawn walls and other obstacles
BOXSIZE = WINDOWWIDTH - 100
WALLWIDTH = 50
obstacles = dispUtils.createWalls(windowSurface,BOXSIZE,WALLWIDTH)
dispUtils.drawObstacles(windowSurface, [0,0,0], obstacles)

# box
boxX = int(random.uniform(200, 800))
boxY = int(random.uniform(200, 800))

blacklist = []
while not dispUtils.noCollideSpawnCheck(boxX,boxY,blacklist,200):
    boxX = int(random.uniform(200, 800))
    boxY = int(random.uniform(200, 800))

box = {'position':[boxX,boxY], 'width':80, 'height': 120}
if spawnBox:
    obstacles.append(dispUtils.centreRecttoPoly(box))