Skip to content

Instantly share code, notes, and snippets.

@stamaniorec
Created October 31, 2015 11:49
Show Gist options
  • Select an option

  • Save stamaniorec/247bd63fee23d08ac266 to your computer and use it in GitHub Desktop.

Select an option

Save stamaniorec/247bd63fee23d08ac266 to your computer and use it in GitHub Desktop.
#pygame load and draw image
import os, sys
def load_image(name):
fullname = os.path.join('data', name)
try:
image = pygame.image.load(fullname)
except pygame.error, message:
print 'Cannot load image:', name
raise SystemExit, message
image = image.convert()
return image
image = load_image('image.jpg')
image = pygame.transform.scale(image, (desired_width,desired_height))
game_display.blit(image, (dest_x,dest_y))
pygame.display.update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment