import pygame
import sys
import pygame.key
width=1080
height=720
FPS=120
WHITE=(255,255,255)
pygame.init()
screen=pygame.display.set_mode((1080,720))
pygame.display.set_caption('my.game')
clock=pygame.time.Clock()
velocity = 12
x=-400
y=-200
run=True
BLACK = ( 0, 0, 0)
while run:
clock.tick(FPS)
background_image = pygame.image.load("fonroad.jpg").convert()
screen.blit(background_image, [0, 0])
for event in pygame.event.get():
if event.type==pygame.quit:
run = False
pygame.quit()
quit()
player_img=pygame.image.load('car.png').convert()
player_img.set_colorkey(BLACK)
screen.blit(player_img,(440,520))
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
x -= velocity
if event.key == pygame.K_RIGHT:
x += velocity
if event.key == pygame.K_UP:
y -= velocity
if event.key == pygame.K_DOWN:
y += velocity
pygame.display.update()
for event in pygame.event.get():
if event.type==pygame.quit:
run = False
pygame.quit()
quit()
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
x -= velocity
if event.key == pygame.K_RIGHT:
x += velocity
if event.key == pygame.K_UP:
y -= velocity
if event.key == pygame.K_DOWN:
y += velocity