import pygame
import sys
from gun import gun
def run():
pygame.init()
screen = pygame.display.set_mode((800, 800))
pygame.display.set_caption("Космическая оборона")
bg_color = (0, 0, 0)
gun = gun(screen)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
screen.fill(bg_color)
gun.autput()
pygame.display.flip()
run()
import pygame
class gun():
def __init__(self, screen):
"""инициализация пушки"""
self.screen = screen
self.image = pygame.image.load('images/pixil-frame-0.png')
self.rect = self.image.get_rect()
self.screen_rect = screen.get_rect()
self.rect.centerx = self.screen_rect.centerx
self.rect.bottom = self.screen_rect.bottom
def output(self):
"""рисование пушки"""
self.screen.blit(self.image, self.rect)