0

The code sample below does not work as intended.

import pygame as pg
import time as t  
import math as m
import random as r
import os  # this efficiently imports the necessary modules


pg.init()

screen = pg.display.set_mode((500, 500))
pg.display.set_caption("bullet hell")
clock = pg.time.Clock()
clock.tick(60)

player = pg.image.load("player.png")


def loopkill():
    if event.type == pg.QUIT:
        running = False


def loop():  # this is the mainloop for pygame
    running = True

    while running:

        for event in pg.event.get():
            t.sleep(100)
            if event.type == pg.QUIT:
                running = False
            if event.type == pg.KEYDOWN:
                print("ready")

            pg.surface.blit(player, (250, 250))
            g.draw(screen)
            g.update()
            pg.display.flip()

       # Quit Pygame
    pg.quit()


loop()

Expected a player sprite, however got a blank screen instead.

moken
  • 3,227
  • 8
  • 13
  • 23

1 Answers1

2

I'm suspicious of the t.sleep(100) that would make your program stop for 100 seconds every time there is an event. Also, the functions which draw the screen are within the event loop, so they are only called when there are events.

Telan
  • 281
  • 1
  • 5
  • its an old program, that was to prevent window closing, i removed it and did some fiddling to get a window up permanence – patrick horan Feb 14 '23 at 04:05