OMFGNuts

Gabe

Apr 5th, 2011
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. __author__ = 'Nuts)'
  2. import sys, pygame, random, math
  3. from pygame.locals import *
  4. #from pygame.constants import QUIT
  5.  
  6. bg_image = "background.jpg"
  7. cursr_image = "gaben.jpg"
  8. target = "ep3.jpg"
  9. pygame.mixer.pre_init(44100, 16,2, 4096)
  10. pygame.init()
  11. scrsize = 800, 600
  12. pygame.display.set_caption("game")
  13. screen = pygame.display.set_mode(scrsize,0,32)
  14. cursor = pygame.image.load(cursr_image).convert_alpha()
  15. backgr = pygame.image.load(bg_image).convert()
  16. episode3= pygame.image.load(target).convert_alpha()
  17. #sound = pygame.mixer.music.load("ost.ogg")
  18. #pygame.mixer.music.play(loops=-1, start=0.0)
  19. def randomness():
  20.     x2=random.randint(0,720)
  21.     y2=random.randint(0,520)
  22.     return x2,y2
  23. x2,y2 = randomness()
  24.  
  25. def getposition():
  26.     x1,y1 = pygame.mouse.get_pos()
  27.     return x1,y1
  28. x1,y1 = getposition()
  29.  
  30. def distance(x2,y2,x1,y1):
  31.     d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
  32.     return d
  33. d = distance(x2,y2,x1,y1)
  34. pygame.display.flip()
  35. while True:
  36.         x1,y1 = getposition()
  37.         d = distance(x2,y2,x1,y1)
  38.         screen.blit(cursor,(x1,y1))
  39.         pygame.display.flip()
  40.         screen.blit(backgr,(0,0))
  41.         if d <= 90:
  42.             x2,y2 = randomness()
  43.             screen.blit(episode3,(x2,y2))
  44.             pygame.display.flip()
  45.         x1 -= cursor.get_width() / 2
  46.         y1 -= cursor.get_height() / 2
  47.         for event in pygame.event.get():
  48.             if event.type == QUIT:
  49.                         pygame.quit()
  50.                         sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment