0
import pygame
from pygame.locals import *
screen=pygame.display.set_mode()
nin=pygame.image.load('/home/satyajit/Desktop/nincompoop0001.bmp')
screen.blit(nin,(50,100))

according to the code i should get a screen with an image of nin on it . But I only get a black screen which doesnt go even though i press the exit button on it. how to get the image on the screen?

3 Answers 3

2

You have to call pygame.display.flip() whenever you want the screen to be updated.

Sign up to request clarification or add additional context in comments.

Comments

2

As well as calling pygame.display.flip() (or pygame.display.update() if it is a software based surface). you will also need to call pygame.init() at the start of your program and eventually call pygame.quit() to close down the window and do cleanup.

you code might then be

import pygame,time
from pygame.locals import *
pygame.init()
screen=pygame.display.set_mode()
nin=pygame.image.load('/home/satyajit/Desktop/nincompoop0001.bmp')
screen.blit(nin,(50,100))
pygame.display.flip()
time.sleep(10)
pygame.quit()

Comments

0

Try this:

import pygame
from pygame.locals import *
screen=pygame.display.set_mode()
nin=pygame.image.load('nincompoop0001.bmp')
screen.blit(nin,(50,100))

Then, place the image in the same directory as your script.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.