Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import random
- import pygame, sys
- from pygame.locals import *
- pygame.init()
- (windows_width, windows_height, windows_title) = (600, 400, "Simple Figure")
- 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 = (0,0,255)
- color_normal = (0,255,0)
- color_collide = (255,0,0)
- rect_list = []
- cicle_range = range(10)
- x = 0
- while x<10:
- rect_list.append(Rect(500 * random.random(), 300 * random.random(), 100, 100))
- print x
- x+=1
- collide_index = rect_1.collidelistall(rect_list)
- 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
- pygame.draw.rect(screen, rect_1_color, rect_1)
- x = 0
- while x<10:
- if x in collide_index:
- temp_color = color_collide
- else:
- temp_color = color_normal
- pygame.draw.rect(screen, temp_color, rect_list[x],4)
- x+=1
- pygame.display.update()
- pygame.quit()
- #destroy data here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement