Giới thiệu sản phẩm

import pygame,random
from car import Car
pygame.init()
win=pygame.display.set_mode((500,500))
pygame.display.set_icon(pygame.image.load('images.jpg'))
pygame.display.set_caption('car racing')
green=(20,255,140)
gray=(210,210,210)
white=(255,255,255)
red=(255,0,0)
purple=(255,0,255)
all_sprites_list=pygame.sprite.Group()
playerCar=Car(red,20,30)
playerCar.rect.x=200
playerCar.rect.y=300
all_sprites_list.add(playerCar)

done=True
clock=pygame.time.Clock()
while done:
    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            done=False
        elif event.type==pygame.KEYDOWN:
             if event.key==pygame.K_x:
                  done = False
    keys=pygame.key.get_pressed()
    if keys[pygame.K_LEFT]:
         playerCar.moveleft(5)
    if keys[pygame.K_RIGHT]:
         playerCar.moveright(5)
        
    all_sprites_list.update()
    win.fill(green)
    pygame.draw.rect(win,gray,[40,0,410,500])
    pygame.draw.line(win,white,[40,0],[40,600],5)
    pygame.draw.line(win,white,[115,0],[115,600],5)
    pygame.draw.line(win,white,[200,0],[200,600],5)
    pygame.draw.line(win,white,[290,0],[290,600],5)
    pygame.draw.line(win,white,[370,0],[370,600],5)
    pygame.draw.line(win,white,[450,0],[450,600],5)
    all_sprites_list.draw(win)
    pygame.display.flip()
    clock.tick(60)


Hình ảnh sản phẩm
Hãy bình luận để nhặt 100 thóc nhé

Đăng nhập để tham gia bình luận

Thông tin tác giả

Địa vị cộng đồng: Nông dân

Sản phẩm cùng tác giả

Sản phẩm liên quan

    Không có sản phẩm nào

Bạn muốn thử làm game không?