/
SergOrloff
/
Game-Rifle-range
Обзор
Документация
Войти
/
SergOrloff
/
Game-Rifle-range
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
main.py
36 строк
1 KB
SergOrloff
Adding program function-ability
01 июл 2024, 03:33
01 июл 2024, 03:33
1cbc85a
Код
Авторство
О чём код?
import pygame import random pygame.init() SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption('Rifle-range game') icon = pygame.image.load('img/image.jpg') pygame.display.set_icon(icon) target_img = pygame.image.load('img/target.png') target_width = 50 target_height = 50 target_x = random.randint(0, SCREEN_WIDTH - target_width) target_y = random.randint(0, SCREEN_HEIGHT - target_height) color = (random.randint(0,255), random.randint(0,255), random.randint(0,255)) running = True while running: screen.fill(color) for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if event.type == pygame.MOUSEBUTTONDOWN: mouse_x, mouse_y = pygame.mouse.get_pos() if target_x < mouse_x < target_x + target_width and target_y < mouse_y < target_y + target_height: target_x = random.randint(0, SCREEN_WIDTH - target_width) target_y = random.randint(0, SCREEN_HEIGHT - target_height) screen.blit(target_img, (target_x, target_y)) pygame.display.update() pygame.quit()