Advertisement
noTformaT

pygame_rect_contains.py

Mar 18th, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. import math
  2. import pygame, sys
  3. from pygame.locals import *
  4. pygame.init()
  5. (windows_width, windows_height, windows_title) = (600, 400, "Rect Contains")
  6. screen = pygame.display.set_mode((windows_width,windows_height),0,32)
  7. pygame.display.set_caption(windows_title)
  8. windows_bgcolor = (255,255,255)
  9. mainLoop = True
  10. clock = pygame.time.Clock()
  11. milli = seconds = 0.0
  12. #initial data here
  13. rect_1 = Rect(100,100,200,200)
  14. rect_2 = Rect(350,110, 180,180)
  15. rect_1_color = (255,0,0)
  16. rect_2_color = (0,255,0)
  17. print "rect_1 contains rect_2 -", bool(rect_1.contains(rect_2))
  18. while mainLoop:
  19.     for event in pygame.event.get():
  20.         if event.type == QUIT:
  21.             mainLoop = False
  22.     milli = clock.tick()
  23.     seconds = milli / 1000.0
  24.     screen.fill(windows_bgcolor)
  25.     #create frame here
  26.     pygame.draw.rect(screen, rect_1_color, rect_1)
  27.     pygame.draw.rect(screen, rect_2_color, rect_2)
  28.     pygame.display.update()
  29. pygame.quit()
  30. #destroy data here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement