-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexploration.py
More file actions
48 lines (38 loc) · 1.12 KB
/
exploration.py
File metadata and controls
48 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import sys
import pygame
from car import Car
# CONSTANTS:
scaling = 2
global WIDTH
SCREENSIZE = WIDTH, HEIGHT = 400*scaling,400*scaling
BLACK = (0, 0, 0)
GREY = (160, 160, 160)
dt = int(0.01 *1000) # Time interval of simulations in milliseconds
# function to draw Map mentioned in the task
def makeMap(screen):
map = pygame.image.load('map2.png')
map = pygame.transform.scale(map, (WIDTH, HEIGHT))
return map
def checkexit():
while(1):
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit(0)
def draw_cars(car, screen):
car.draw(screen)
car.draw_lidar(screen)
if __name__ == '__main__':
pygame.init()
clock = pygame.time.Clock()
screen = pygame.display.set_mode((int(WIDTH),int(HEIGHT)))
map = makeMap(screen)
car = Car()
## Simulate the motion every dt seconds
while (1):
screen.blit(map, (0, 0))
car.update(map)
draw_cars(car, screen)
clock.tick(0)
pygame.time.delay(dt) # Simulate the car every dt milliseconds
pygame.display.update()
checkexit()