Answer the question
In order to leave comments, you need to log in
Why is the sprite not being rendered in pygame?
Why is the sprite not being drawn?
import pygame
import sys
from gun import Gun
def run():
pygame.init()
screen = pygame.display.set_mode((1200, 600))
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.output()
pygame.display.flip()
run()
import pygame
class Gun():
def __init__(self, screen):
"""инициализауия пушки"""
self.screen = screen
self.image = pygame.image.load('images/kosmpsih.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)
Answer the question
In order to leave comments, you need to log in
screen.fill(bg_color)
gun.output()
pygame.display.flip()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question