Добавить старт стоп в автомобиль
<pre>#Wagen Detectie #Grensdetectie #Baris Güzle import pygame #Kleuren Zwart = (0,0,0) Wit = (255,255,255) Donker_Groen = (0,130,0) Bruin = (75,35,0) #Spelgegevens screen_width = 800 #Schermbreedte screen_heigth = 600 #Schermhoogte FPS = 100 #Frames/Seconde #Cargegevens car_width = 60 car_heigth = 10 car_wheel = 5 car_speed = 2 car_positionX = screen_width*0.1 car_positionY = screen_heigth*0.9 pygame.init() gameScreen = pygame.display.set_mode((screen_width,screen_heigth)) pygame.display.set_caption('Car') game = True clock = pygame.time.Clock() def car_build(startX, startY): x = int (startX) y = int (startY) #Wielen.Cirkel pygame.draw.circle(gameScreen, Zwart, (x-15, y),car_wheel) pygame.draw.circle(gameScreen, Zwart, (x+15, y),car_wheel) #Lichaam.Rechthoke pygame.draw.rect(gameScreen, Bruin,(x-20, y-8, car_width-20, car_heigth)) def game_loop(): carY = car_positionY carX = car_positionX car_speed = 2 while game: gameScreen.fill(Wit) for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() car_build(carX,car_positionY ) pygame.draw.rect(gameScreen, Donker_Groen, (0,int(carY)+5, screen_width, 15)) pygame.draw.rect(gameScreen, Zwart, [750,500,10,50]) pygame.draw.rect(gameScreen, Zwart, [50,500,10,50]) pygame.display.update() if carX + 10 > 750: car_speed =-2 if carX < 75: car_speed = 2 carX += car_speed clock.tick (FPS) #Game game_loop()
Что я уже пробовал:
I have a school project. So I had to write a program, and I did. But the only thing that I need in my program is a start stop. The car has to stop when I press Space and start when I press for example "B".