#!/usr/bin/python # Actual game demo version is 0.0.4 but I am calling this Version 9.0c_September_2011 # This game demo was designed and written by Kristian Naugle # This Danger From Above game demo was began on September 22nd 2011 and is my first attempt at writing anything in the Python programming language and to develop games using Pygame. # Visit the Danger From Above website, http://www.gaming.nauglefest.net/dfa import sys, pygame from pygame.locals import * pygame.init() squawk = pygame.mixer.Sound("bluejay-call.wav") #plays sound on an event. clock = pygame.time.Clock() #makes the frame limiter posible. size = width, height = 800,600 #program window size background = pygame.image.load("grass-background-800x600.png") #grassy background screen = pygame.display.set_mode(size) #sizes the screen #begin the image position variables carpx = 330 #horizontal position for the car carpy = 610 #vertical position for the car semipx = 400 #horizontal position of semi semipy = 660 #vertical position of semi road = pygame.image.load("road.png") road = pygame.transform.scale(road, (192,192)) bird = pygame.image.load("bird.png") bird = pygame.transform.scale(bird, (96,96)) tree01 = pygame.image.load("tree.png") tree01 = pygame.transform.scale(tree01, (128,128)) car = pygame.image.load("red-car.png") car = pygame.transform.scale(car, (64,85)) semi = pygame.image.load("semi.png") semi = pygame.transform.scale(semi, (64,256)) pond = pygame.image.load("pond.png") pond = pygame.transform.scale(pond, (192,192)) #the transform.scale will increase the size of an image while 1: #game loop. mx1,my1 = pygame.mouse.get_pos() #Makes Pygame get the position of the mouse cursor on the screen for event in pygame.event.get(): if event.type == pygame.QUIT:sys.exit() #exits the elif event.type == KEYDOWN and event.key == K_ESCAPE:sys.exit() #exits the game by pressing elif event.type == MOUSEBUTTONDOWN and pygame.mouse.get_pressed()[0]:squawk.play() #makes the bird squawk on left mouse button click elif event.type == KEYDOWN and event.key == K_SPACE:pygame.image.save(screen, "screenshot.png") #saves a screenshot of current Pygame window when pressing the spacebar screen.blit(background,(0,0)) #draws the background with the grass screen.blit(tree01,(80,240)) screen.blit(tree01,(600,48)) screen.blit(tree01,(470,460)) screen.blit(road,(300,0)) screen.blit(road,(300,192)) screen.blit(road,(300,384)) screen.blit(road,(300,576)) screen.blit(car,(carpx,carpy)) screen.blit(semi,(semipx,semipy)) screen.blit(pond,(520,275)) #Pygame displays an image to the screen whe you blit it, the pond is positioned 520 pixels from the left of the screen along with 275 pixels from the top-left of the screen screen.blit(bird,(mx1-48,my1-48)) #bird follows the mouse cursor and is centered. pygame.display.flip() carpy = carpy-5 semipy = semipy-3 clock.tick(15) #frame limiter to reduce CPU usage. For some reason my CPU usage went back up to 100% when I began drawing a background of images and animating items. # All hail Mr.Child, full of magic and blessings, he shall peck out the eyes of the trouble makers with his monkey-beak.