Advertisement
noTformaT

pygame_rect_cp.py

Mar 18th, 2011
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 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 Collidepoint")
  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(200,100,200,200)
  14. rect_1_color_normal = (0,0,255)
  15. rect_1_color_over = (0, 255,255)
  16. rect_1_color = rect_1_color_normal
  17. while mainLoop:
  18.     for event in pygame.event.get():
  19.         if event.type == QUIT:
  20.             mainLoop = False
  21.     screen.fill(windows_bgcolor)
  22.     milli = clock.tick(40)
  23.     seconds = milli / 1000.0
  24.     #create frame here
  25.     if rect_1.collidepoint(pygame.mouse.get_pos()):
  26.         rect_1_color = rect_1_color_over
  27.     else:
  28.         rect_1_color = rect_1_color_normal
  29.     pygame.draw.rect(screen, rect_1_color, rect_1)
  30.     pygame.display.update()
  31. pygame.quit()
  32. #destroy data here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement