-
Notifications
You must be signed in to change notification settings - Fork 0
/
CD_Scenario1.py
36 lines (35 loc) · 987 Bytes
/
CD_Scenario1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pygame
import sys
from pygame.locals import *
white = (255,255,255)
red = (255, 0, 0)
blue = (0, 0, 255)
green = (0, 255, 0)
black = (0, 0, 0)
yellow = (255, 255, 0)
frame = pygame.display.set_mode((200, 200)) #scaled by 2
pygame.display.set_caption('Trapezoidal decomposition')
frame.fill(white)
x = 0;
y = 0;
while True:
pygame.draw.line(frame,red,[40, 120], [100, 50],2)
pygame.draw.line(frame,red,[100, 50], [150, 120],2)
pygame.draw.line(frame,red,[40, 120], [150, 120],2)
pygame.draw.rect(frame, white, [x, 0, 2, 200])
x = x + 0.001
pygame.draw.rect(frame, blue, [x, 0, 2, 200])
print x
if(x > 40):
pygame.draw.rect(frame, yellow, [40, 0, 2, 200])
if(x > 100):
pygame.draw.rect(frame, yellow, [100, 0, 2, 50])
if(x >150):
pygame.draw.rect(frame, yellow, [150, 0, 2, 200])
#pygame.draw.Rect(frame,red,[200, 300], [450, 600],5)
for event in pygame.event.get():
print event
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()