Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Nuts)'
- import sys, pygame, random, math
- from pygame.locals import *
- #from pygame.constants import QUIT
- bg_image = "background.jpg"
- cursr_image = "gaben.jpg"
- target = "ep3.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()
- episode3= 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,720)
- y2=random.randint(0,520)
- return x2,y2
- x2,y2 = randomness()
- def getposition():
- x1,y1 = pygame.mouse.get_pos()
- return x1,y1
- x1,y1 = getposition()
- def distance(x2,y2,x1,y1):
- d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
- return d
- d = distance(x2,y2,x1,y1)
- pygame.display.flip()
- while True:
- x1,y1 = getposition()
- d = distance(x2,y2,x1,y1)
- screen.blit(cursor,(x1,y1))
- pygame.display.flip()
- screen.blit(backgr,(0,0))
- if d <= 90:
- x2,y2 = randomness()
- screen.blit(episode3,(x2,y2))
- pygame.display.flip()
- x1 -= cursor.get_width() / 2
- y1 -= cursor.get_height() / 2
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment