-
Notifications
You must be signed in to change notification settings - Fork 0
/
DVD Logo.py
108 lines (86 loc) · 3.08 KB
/
DVD Logo.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import sys, random, time
import bext
Width, Height = bext.size()
Width -= 1
Number_of_Logos = 1
Pause_Amount = 0.2
Colours = ['red','green','blue','cyan']
Up_Right = 'ur'
Up_Left = 'ul'
Down_Right = 'dr'
Down_Left = 'dl'
Directions = (Up_Left, Up_Right, Down_Left, Down_Right)
Colour = 'colour'
X = 'x'
Y = 'y'
DIR = 'direction'
def main():
bext.clear()
logos = []
for i in range(Number_of_Logos):
logos.append({Colour: random.choice(Colours),
X: random.randint(1, Width - 4),
Y: random.randint(1, Height - 4),
DIR: random.choice(Directions)})
if logos[-1][X] % 2 == 1:
logos[-1][X] -= 1
cornerBounces = 0
while True:
for logo in logos:
bext.goto(logo[X], logo[Y])
print(' ', end='')
originalDirection = logo[DIR]
if logo[X] == 0 and logo[Y] == 0:
logo[DIR] = Down_Right
cornerBounces += 1
elif logo[X] == 0 and logo[Y] == Height - 1:
logo[DIR] = Up_Right
cornerBounces += 1
elif logo[X] == Width - 3 and logo[Y] == 0:
logo[DIR] = Down_Left
cornerBounces += 1
elif logo[X] == Width -3 and logo[Y] == Height - 1:
logo[DIR] = Up_Left
cornerBounces += 1
elif logo[X] == 0 and logo[DIR] == Up_Left:
logo[DIR] = Up_Right
elif logo[X] == 0 and logo[DIR] == Down_Left:
logo[DIR] = Down_Right
elif logo[Y] == 0 and logo[DIR] == Up_Left:
logo[DIR] = Down_Left
elif logo[Y] == 0 and logo[DIR] == Up_Right:
logo[DIR] = Down_Right
elif logo[X] == Width - 3 and logo[DIR] == Up_Right:
logo[DIR] = Up_Left
elif logo[X] == Width - 3 and logo[DIR] == Down_Right:
logo[DIR] = Down_Left
elif logo[Y] == Height - 1 and logo[DIR] == Down_Left:
logo[DIR] = Up_Left
elif logo[Y] == Height - 1 and logo[DIR] == Down_Right:
logo[DIR] = Up_Right
if logo[DIR] != originalDirection:
logo[Colour] = random.choice(Colours)
if logo[DIR] == Up_Right:
logo[X] += 2
logo[Y] -= 1
if logo[DIR] == Up_Left:
logo[X] -= 2
logo[Y] -= 1
if logo[DIR] == Down_Right:
logo[X] += 2
logo[Y] += 1
if logo[DIR] == Down_Left:
logo[X] -= 2
logo[Y] += 1
bext.goto(5,0)
bext.fg('white')
print(f"Corner Bounces: {cornerBounces}")
for logo in logos:
bext.goto(logo[X], logo[Y])
bext.fg(logo[Colour])
print('DVD', end='')
bext.goto(0,0)
sys.stdout.flush()
time.sleep(Pause_Amount)
if __name__ == '__main__':
main()