import pygame as pg
FPS = 40
pg.init()
clock = pg.time.Clock ()
WIDTH, HEIGHT = 900, 600
screen = pg.display.set_mode ((WIDTH, HEIGHT))
pg.display.set_caption ('Scrolling Background Tester')
background = pg.Surface ((1000, 1000))
background.fill ((200, 200, 200))
bg_x = 0
bg_y = 0
for x in range (100, 1000, 100) :
for y in range (100, 1000, 100) :
pg.draw.rect (background, (0, 0, 0), (x, y, 20, 20))
while True :
for event in pg.event.get () :
if event.type == pg.QUIT :
pg.quit ()
sys.exit ()
keys = pg.key.get_pressed ()
if keys [pg.K_LEFT] :
bg_x += 10
if keys [pg.K_RIGHT] :
bg_x -= 10
if keys [pg.K_UP] :
bg_y += 10
if keys [pg.K_DOWN] :
bg_y -= 10
screen.fill ((0, 0, 0))
screen.blit (background, (bg_x, bg_y))
pg.draw.circle (screen, (200, 0, 0), (450, 290), 20)
pg.display.update ()
clock.tick (FPS)