Advertisement
noTformaT

pygame_rect_cl.py

Mar 19th, 2011
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. import math
  2. import random
  3. import pygame, sys
  4. from pygame.locals import *
  5. pygame.init()
  6. (windows_width, windows_height, windows_title) = (600, 400, "Simple Figure")
  7. screen = pygame.display.set_mode((windows_width,windows_height),0,32)
  8. pygame.display.set_caption(windows_title)
  9. windows_bgcolor = (255,255,255)
  10. mainLoop = True
  11. clock = pygame.time.Clock()
  12. milli = seconds = 0.0
  13. #initial data here
  14. rect_1 = Rect(200,100,200,200)
  15. rect_1_color = (0,0,255)
  16. color_normal = (0,255,0)
  17. color_collide = (255,0,0)
  18. rect_list = []
  19. cicle_range = range(10)
  20. x = 0
  21. while x<10:
  22.     rect_list.append(Rect(500 * random.random(), 300 * random.random(), 100, 100))
  23.     print x
  24.     x+=1
  25. collide_index = rect_1.collidelistall(rect_list)
  26. while mainLoop:
  27.     for event in pygame.event.get():
  28.         if event.type == QUIT:
  29.             mainLoop = False
  30.     screen.fill(windows_bgcolor)
  31.     milli = clock.tick(40)
  32.     seconds = milli / 1000.0
  33.     #create frame here
  34.     pygame.draw.rect(screen, rect_1_color, rect_1)
  35.     x = 0
  36.     while x<10:
  37.         if x in collide_index:
  38.             temp_color = color_collide
  39.         else:
  40.             temp_color = color_normal
  41.         pygame.draw.rect(screen, temp_color, rect_list[x],4)
  42.         x+=1
  43.     pygame.display.update()
  44. pygame.quit()
  45. #destroy data here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement