Advertisement
jabela

Simple Pygame box detection

Dec 16th, 2015
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import pygame
  2.  
  3. pygame.init()
  4. pygame.display.set_caption('Crash!')
  5. window = pygame.display.set_mode((300, 300))
  6. running = True
  7.  
  8. #Draw Once
  9. rectplace = pygame.draw.rect(window, (255, 0, 0),(100, 100, 100, 100))
  10. pygame.display.update()
  11. #Main Loop
  12. while running:
  13.     pos = pygame.mouse.get_pos()
  14.     if rectplace.collidepoint(pos):
  15.         print("Don't touch me!")
  16.     for event in pygame.event.get():
  17.         if event.type == pygame.QUIT:
  18.             running = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement