Untitled

23
mail@pastecode.io avatar
unknown
plain_text
a month ago
1.9 kB
7
Indexable
Never
import pygame

width = 400  # высота
height = 400  # ширина
fps = 30

pygame.init()
screen = pygame.display.set_mode((width, height))  # задаём разрешение экрана
clock = pygame.time.Clock()  # задаём fps

image = pygame.image.load('raketa.png')  # загружаем картинку
# image_scaled = pygame.transform.scale(image, (image.get_width() * 2, image.get_height() * 2))

fon = (10, 0, 45)  # красный цвет
color = (255, 250, 0)
run = True
eyes = 13
m = 0

x = 200
y = 200

while run:
    clock.tick(fps)
    events = pygame.event.get()  # события: считывание нажатия на клавишу
    font = pygame.font.Font(None, 30)  # Задаём шрифт
    text = font.render('Hello world!', True, (250, 250, 250))  # создали текст

    # pygame.draw.circle(screen, color, (200, 200), 25)
    screen.fill(fon)  # задаём фон
    pygame.draw.circle(screen, color, (200, 200), 60)
    pygame.draw.circle(screen, fon, (170, 180), eyes)
    pygame.draw.circle(screen, fon, (230, 180), eyes)
    pygame.draw.line(screen, fon, (170, 220), (230, 220), 10)
    # screen.blit(text, (200, 50))  # Отображаем на экране текст

    screen.blit(image, (x, y))
    if eyes > 13:
        m = 0
    if eyes < 5:
        m = 1
    if m == 0:
        eyes -= 0.1
    else:
        eyes += 0.1

    # pygame.draw.polygon(screen, (0, 0, 0), [(100, 100), (200, 100), (300, 300), (100, 300)])

    pygame.display.update()  # обновляем экран

    key = pygame.key.get_pressed()

    if key[pygame.K_LEFT]:
        x = x - 10
    if key[pygame.K_RIGHT]:
        x = x + 10
    if key[pygame.K_UP]:
        y = y - 10
    if key[pygame.K_DOWN]:
        y = y + 10

    for i in events:
        if i.type == pygame.QUIT:
            run = False
pygame.quit()
Leave a Comment