954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Loading Problems

Hi cannot get images to load any help would be gratefully recieved...

import pygame
import sys
from pygame.locals import *


sys.path.append ("C:\\Python26\Bits\player.png")
###Will not Load saved image
#triedC:\Python26\Bits\player.png
# and tried C:\Python26\Bits
#confusing or what!!!

#Whole program not here



# set up the window
WINDOWWIDTH = 400
WINDOWHEIGHT = 400
windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32)
pygame.display.set_caption('Sprites and Sound')

player = pygame.Rect(300, 100, 40, 40)
playerImage = pygame.image.load('player.png')
playerStretchedImage = pygame.transform.scale(playerImage, (40, 40))

windowSurface.blit(playerStretchedImage, player)

pygame.display.update()


while True:
   # check for the QUIT event
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
FAITH2011
Light Poster
29 posts since Dec 2010
Reputation Points: 10
Solved Threads: 2
 
pygame.image.load('player.png')

Give the fullpath to the image file ok ?

pygame.image.load('fullimagepath')


Then forget about the sys.path.append() stuff.

image is not a module.
;)

richieking
Master Poster
764 posts since Jun 2009
Reputation Points: 61
Solved Threads: 152
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: