UtamaDonny

main.py

Jun 8th, 2021 (edited)
105
262 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pygame
  2. import math
  3. import env,sensors
  4.  
  5. environment = env.buildEnvironment((600,1200))
  6. environment.originalMap=environment.map.copy()
  7. laser=sensors.LaserSensor(200,environment.originalMap,uncertainty=(0.5,0.01))
  8. environment.map.fill((0,0,0))
  9. environment.infomap=environment.map.copy()
  10.  
  11. running = True
  12.  
  13. while running :
  14.     sensorON=False
  15.     for event in pygame.event.get():
  16.         if event.type == pygame.QUIT:
  17.             running=False
  18.         if pygame.mouse.get_focused():
  19.             sensorON=True
  20.         elif not pygame.mouse.get_focused():
  21.             sensorON=False
  22.     if sensorON:
  23.         position=pygame.mouse.get_pos()
  24.         laser.position=position
  25.         sensor_data=laser.sense_obstacle()
  26.         environment.dataStorage(sensor_data)
  27.         environment.show_sensorData()
  28.     environment.map.blit(environment.infomap,(0,0))
  29.     pygame.display.update()
RAW Paste Data