Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- import random
- background_colour = (17,17,17);
- (width, height) = (900, 900);
- score = 0;
- screen = pygame.display.set_mode((width, height));
- pygame.display.set_caption('Stupid Game');
- screen.fill(background_colour);
- pygame.font.init();
- fonts = pygame.font.SysFont('Raleway', 30);
- score = fonts.render('Score: 0', False, (255,255,255));
- screen.blit(score,(5,5));
- pygame.display.flip()
- currentx = 0;
- currenty = 0;
- currentxy = 0;
- def resetgame():
- pygame.draw.rect(screen,(17,17,17),(0,40,900,860));
- pygame.display.update();
- running = True
- resetgame();
- r = random.randint(50, 200);
- currentxy=r;
- currentx=random.randint(0, 900);
- currenty=random.randint(40, 900);
- pygame.draw.rect(screen,(34,34,34),(currentx,currenty,r,r));
- pygame.display.update()
- while running:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False;
- if event.type == pygame.MOUSEBUTTONUP:
- xpos = str(pygame.mouse.get_pos()[0])
- ypos = str(pygame.mouse.get_pos()[1])
- tocheck1 = currentx;
- tocheck2 = currentx+currentxy;
- tocheck3 = currenty;
- tocheck4 = currenty+currentxy;
- if (int(xpos)>=tocheck1 and int(xpos)<=tocheck2 and int(ypos)>=tocheck3 and int(ypos)<=tocheck4 ):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement