Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import pygame, sys
- from pygame.locals import *
- pygame.init()
- (windows_width, windows_height, windows_title) = (600, 400, "Rect Collidepoint")
- screen = pygame.display.set_mode((windows_width,windows_height),0,32)
- pygame.display.set_caption(windows_title)
- windows_bgcolor = (255,255,255)
- mainLoop = True
- clock = pygame.time.Clock()
- milli = seconds = 0.0
- #initial data here
- rect_1 = Rect(200,100,200,200)
- rect_1_color_normal = (0,0,255)
- rect_1_color_over = (0, 255,255)
- rect_1_color = rect_1_color_normal
- while mainLoop:
- for event in pygame.event.get():
- if event.type == QUIT:
- mainLoop = False
- screen.fill(windows_bgcolor)
- milli = clock.tick(40)
- seconds = milli / 1000.0
- #create frame here
- if rect_1.collidepoint(pygame.mouse.get_pos()):
- rect_1_color = rect_1_color_over
- else:
- rect_1_color = rect_1_color_normal
- pygame.draw.rect(screen, rect_1_color, rect_1)
- pygame.display.update()
- pygame.quit()
- #destroy data here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement