-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrafficSignal.py
More file actions
43 lines (28 loc) · 847 Bytes
/
trafficSignal.py
File metadata and controls
43 lines (28 loc) · 847 Bytes
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
37
38
39
40
41
42
43
import time
import pygame
class TrafficSignal:
def __init__(self):
self.color = 0 # 0 for red , 1 for yellow, 2 for green
def green():
UpSignal.color = 1
UpSignal.image = pygame.image.load("Images//yellow.png")
UpSignal.color = 2
UpSignal.image = pygame.image.load("Images//green.png")
def red():
UpSignal.color = 0
UpSignal.image = pygame.image.load("Images//red.png")
def yellow():
UpSignal.color = 1
UpSignal.image = pygame.image.load("Images//yellow.png")
def isRed():
return UpSignal.color == 0
def isYellow():
return UpSignal.color == 1
def isGreen():
return UpSignal.color == 2
class UpSignal:
image = pygame.image.load("Images//red.png")
rect = pygame.rect.Rect(0, 0, image.get_width(), image.get_height())
rect.x = 330
rect.y = 655
color = 0