im trying to make a rectangle on my screen and the rectangle shows up but for a split second after i click the close button this is my code in the main.py:
main.py (Size: 570 bytes / Downloads: 234)
tiles.py (Size: 236 bytes / Downloads: 240)
import pygame from settings import * from tiles import * background_colour = (0, 0, 0) screen_width = 800 screen_height = 600 screen = pygame.display.set_mode((screen_width, screen_height)) test_tile = pygame.sprite.Group(Tile((100, 100), 200)) pygame.display.set_caption("my screen") screen.fill(background_colour) pygame.display.flip() running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.display.update() clock.tick(60)and this is my code in the tilels.py:
import pygame class Tile(pygame.sprite.Sprite): def __init__(self,pos,size): super().__init__() self.image = pygame.Surface((size,size)) self.image.fill('grey') self.rect = self.image.get_rect(topleft = pos)so i dont know how to make it show up while it is running please help.
Larz60+ write Mar-25-2022, 03:21 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please use BBCode on future posts.
I also took the liberty, and reformatted the first script to make it more readable.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please use BBCode on future posts.
I also took the liberty, and reformatted the first script to make it more readable.