# Look At This Rock # By Al Sweigart # (C) 1973 Dynavid Untersoft Inc. # For a free 87-page catalog of all of Dynavid Untersoft Inc.'s exciting games, # send a self-addressed stamped envelope to: # Dynavid Untersoft Inc. # PO BOX 10110 # San Burntington, CA 94130 # http://inventwithpython.com/lookatthisrock # Wayne Wilkinson http://www.flickr.com/photos/waynewilkinson/6216151231/ import pygame, sys from pygame.locals import * pygame.init() FPS = 2 # the rock doesn't really change that much. fpsClock = pygame.time.Clock() # set up the window WINDOWSURF = pygame.display.set_mode((400, 300), 0, 32) pygame.display.set_caption('Look At This Rock') WHITE = (255, 255, 255) BLACK = (0, 0, 0) rockImg = pygame.image.load('rock1.png') fontObj = pygame.font.Font('freesansbold.ttf', 12) score = 0 while True: # the main game loop WINDOWSURF.fill(WHITE) WINDOWSURF.blit(rockImg, (100, 100)) textSurfaceObj = fontObj.render('Score: ' + str(score), True, BLACK) textRectObj = textSurfaceObj.get_rect() textRectObj.bottomleft = (10, 290) WINDOWSURF.blit(textSurfaceObj, textRectObj) for event in pygame.event.get(): if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE): pygame.quit() sys.exit() pygame.display.update() fpsClock.tick(FPS)