Search code examples
pythonpygamepyglet

Pygame.image.load Not Working?


I am a beginner in Pygame and was following this tutorial to build a simple Minecraft game in Pygame. I am following this tutorial http://usingpython.com/events/, and pygame.image.load() will not show.

Here is my code (the main parts):

#Game Dimensions
TILESIZE = 20
MAPWIDTH = 30
MAPHEIGHT = 20

#Player and position
PLAYER = pygame.image.load('Player.png')
playerPos = [0, 0]

while True:
#User Events
for event in pygame.event.get():
    #If they want to quit
    if event.type == QUIT:
        pygame.quit()
        sys.exit()
    elif event.type == K_RIGHT:
        if (event.key == K_RIGHT):
            playerPos[0] += 1

#Everything between here and

#Display the player
DISPLAYSURF.blit(PLAYER, (playerPos[0]*TILESIZE, playerPos[1]*TILESIZE))

for row in range(MAPHEIGHT):
    for column in range(MAPWIDTH):
        DISPLAYSURF.blit(textures[tilemap[row][column]], (column*TILESIZE, row*TILESIZE))

#Here
#Updates screen
pygame.display.update()

Player.png is an image of a circle that is 20px by 20px

Thanks for the help (:


Solution

  • Draw the player after you draw the tiles. It's likely getting overwritten.