How can I load a huge image with pygame as a background?

I'm making a fighting game in pygame but whenever I load a background (940x680 PNG) the program starts to lag really badly, here is my code:

#import section
import os
import pygame
import time
from pygame.locals import *

#end of import section

#initiazing pygame
print "Loaded Pygame 100%"

width, height = 940,680

#opening window
screen = pygame.display.set_mode((width, height))

background = [0,0]

#loading images
back = pygame.image.load("resources/image/Back.png")

print "Loaded graphics 100%"

while 1:

    #clear to reload

    #drawing background
    screen.blit(back, background )


This may be a newbie question but I just started so yeah...


In pygame you need to use this code you wrote.

#clear to reload

#drawing background
screen.blit(back, background )


If you add a player to the screen and then move him. You will notice that unless you redraw the background, you will see the character more than once.

Pygame doesn't just let you add an image to the screen and move it around, you must redraw the background to get rid of a previous frame.

Another thing you should add to your code is a wait.

clock = pygame.time.Clock()
FPS = 30

while 1:

This will set the frame rate. I'd say you would generally want this at 30 - 60 frames, depending on the game / hardware.

Your current program is probably redrawing the frame a several hundred times, so this will definately add lag.

When I checked this on my pc Ubuntu 12.04 without a background. i.e. A Black screen.

My frame rate was between 1000 - 2000 FPS.

Need Your Help


sql oracle ddl

Which are the differences between DBMS_UTILITY.EXEC_DDL_STATEMENT and EXECUTE IMMEDIATE?

How to prevent XSS attacks when I need to render HTML from a WYSIWYG editor?

html django security wysiwyg

Non-Technical Background info: I am working for a school and we are building a new website using Django. The teachers that work for the school aren't technologically competent enough to use another