[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] ?scroll a section of the background?

On Tue, 2005-10-18 at 20:51 -0400, Justin Shaw wrote:
> Pygame newbe here and I must be missing something.  I need to scroll a
> section of the screen at each update.  I had hoped I could achieve
> this with Rect.move(), but you already know that didn't work.  If you
> think you might be able to help, please read on.

What you want to do is just blit the screen into itself with an offset. 

import pygame

def ScrollUp(surf):
    r = surf.get_rect().move(0, 1)
    surf.blit(surf, (0, 0), r)

def Main():
    win = pygame.display.set_mode((640, 480))
    img = pygame.image.load("data/liquid.bmp")
    img = pygame.transform.scale2x(img)
    img = pygame.transform.scale2x(img)
    win.blit(img, (0, 0))
    # repeat keydown events every 5 millisec
    pygame.key.set_repeat(5, 5)
    while True:
        event = pygame.event.wait()
        if event.type == pygame.QUIT:
        if event.type == pygame.KEYDOWN:

if __name__ == "__main__":