Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame, sys, os, time,random,math
- from pygame.constants import QUIT
- bg_image = "background.jpg"
- cursr_image = "gaben.jpg"
- target = "image3.jpg"
- pygame.mixer.pre_init(44100, 16,2, 4096)
- pygame.init()
- scrsize = 800, 600
- pygame.display.set_caption("game")
- screen = pygame.display.set_mode(scrsize,0,32)
- cursor = pygame.image.load(cursr_image).convert_alpha()
- backgr = pygame.image.load(bg_image).convert_alpha()
- image3= pygame.image.load(target).convert_alpha()
- sound = pygame.mixer.music.load("ost.ogg")
- pygame.mixer.music.play(loops=-1, start=0.0)
- def randomness():
- x2=random.randint(0,800)
- y2=random.randint(0,600)
- return x2,y2
- (x2,y2) = randomness()
- x1,y1 = pygame.mouse.get_pos()
- def distance():
- d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
- return d
- d = distance()
- while True:
- (x2,y2) = randomness()
- d = distance()
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit();
- sys.exit()
- if d < 100:
- screen.blit(image3,(x2,y2))
- pygame.display.flip()
- else:
- pass
- screen.blit(backgr,(0,0))
- screen.blit(cursor,(x1,y1))
- screen.blit(image3,(x2,y2))
- x1, y1 = pygame.mouse.get_pos()
- x1 -= cursor.get_width() / 2
- y1 -= cursor.get_height() / 2
- pygame.display.flip()
- print (d,x1,y1,x2,y2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement