Reputation: 37
I am making a new game in pygame and the blit function just is not working for me, it should be simple but I just don't know what's wrong.
import pygame
import sys
pygame.init()
clock = pygame.time.Clock()
game = True
WIDTH = 160
HEIGHT = 144
screen = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN)
level = pygame.image.load('RBYG/Level.png')
def redrawGameWindow():
screen.blit(level, (0, 0))
while game:
screen.blit(level,(0, 0))
for event in pygame.event.get():
print(event)
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
sys.exit()
redrawGameWindow()
clock.tick(60)
Upvotes: 0
Views: 33
Reputation: 6857
You're missing pygame.display.flip()
, you have to do that after you blit or nothing will happen. Your redrawGameWindow()
function should flip the display. Also, you're calling screen.blit(level, (0, 0))
twice in your main loop, which may be unnecessary; try just keeping one of them (just make sure to flip()
after).
Upvotes: 2