Advertisement
OMFGNuts

Untitled

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