python - pygame wont load images -


bck = "c:\python27\lib\site-packages\back.jpg" mse = "c:\python27\lib\site-packages\mouse.jpg"  import pygame, sys pygame.locals import *  pygame.init()   screen=pygame.display.set_mode((600,344),0,32)  background=pygame.image.load(bck).convert() mouse_c=pygame.image.load(mse).convert_alpha()  while true:     event in pygame.event.get():         if event.type == quit:             pygame.quit()             sys.exit()      screen.blit(background, (0,0))      x,y = pygame.mouse.get_pos()     x -= mouse_c.get_width()/2     y -= mouse_c.get_height()/2      screen.blit(mouse_c,(x,y))      pygame.display.update() 

i error when using double slash program, images don't show:

file "c:\python27\lib\site-packages\game.py", line 12, in background=pygame.image.load(bck).convert() error: couldn't open c:\python27\lib\site-packagesack.jpg

it doesn't seem able find images

when use double slash or forwards slash runs fine doesn't display images.
i've tried in multiple directories , still doesn't work.

it's better if use / instead of \ in paths, if write print(bck) output this:

'c:\\python27\\lib\\site-packages\x08ack.jpg' 

this because '\b' decoded '\x08'.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -