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 Contains")
- 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(100,100,200,200)
- rect_2 = Rect(350,110, 180,180)
- rect_1_color = (255,0,0)
- rect_2_color = (0,255,0)
- print "rect_1 contains rect_2 -", bool(rect_1.contains(rect_2))
- while mainLoop:
- for event in pygame.event.get():
- if event.type == QUIT:
- mainLoop = False
- milli = clock.tick()
- seconds = milli / 1000.0
- screen.fill(windows_bgcolor)
- #create frame here
- pygame.draw.rect(screen, rect_1_color, rect_1)
- pygame.draw.rect(screen, rect_2_color, rect_2)
- pygame.display.update()
- pygame.quit()
- #destroy data here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement