Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. import pygame
  2. import random
  3.  
  4. background_colour = (17,17,17);
  5. (width, height) = (900, 900);
  6. score = 0;
  7. screen = pygame.display.set_mode((width, height));
  8. pygame.display.set_caption('Stupid Game');
  9. screen.fill(background_colour);
  10. pygame.font.init();
  11. fonts = pygame.font.SysFont('Raleway', 30);
  12. score = fonts.render('Score: 0', False, (255,255,255));
  13. screen.blit(score,(5,5));
  14.  
  15.  
  16.  
  17. pygame.display.flip()
  18.  
  19. currentx = 0;
  20. currenty = 0;
  21. currentxy = 0;
  22.  
  23.  
  24.  
  25.  
  26. def resetgame():
  27. pygame.draw.rect(screen,(17,17,17),(0,40,900,860));
  28. pygame.display.update();
  29.  
  30.  
  31.  
  32.  
  33.  
  34. running = True
  35.  
  36. resetgame();
  37.  
  38. r = random.randint(50, 200);
  39. currentxy=r;
  40. currentx=random.randint(0, 900);
  41. currenty=random.randint(40, 900);
  42. pygame.draw.rect(screen,(34,34,34),(currentx,currenty,r,r));
  43. pygame.display.update()
  44.  
  45. while running:
  46. for event in pygame.event.get():
  47. if event.type == pygame.QUIT:
  48. running = False;
  49.  
  50.  
  51. if event.type == pygame.MOUSEBUTTONUP:
  52. xpos = str(pygame.mouse.get_pos()[0])
  53. ypos = str(pygame.mouse.get_pos()[1])
  54.  
  55.  
  56.  
  57.  
  58. tocheck1 = currentx;
  59. tocheck2 = currentx+currentxy;
  60. tocheck3 = currenty;
  61. tocheck4 = currenty+currentxy;
  62.  
  63. 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