Exemple #1
0
 def draw_map(self):
     """
     Create a map using mapGeneration and filling it to window_surface
     """
     map_data = dispUtils.mapGeneration(self.windowSurface,self.map_type)
     self.windowSurface.fill(map_data[1])
     dispUtils.drawObstacles(self.windowSurface, map_data[2], map_data[0])
# Timing how long the training took
startTime = datetime.now()

# set up pygame
pygame.init()
mainClock = pygame.time.Clock()

# set up the window
WINDOWWIDTH = 1200
WINDOWHEIGHT = 1200
windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))
pygame.display.set_caption('2D Training')

#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)