-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCondensed Version Laser Wars Python program example using variables.py
More file actions
54 lines (41 loc) · 1.43 KB
/
Condensed Version Laser Wars Python program example using variables.py
File metadata and controls
54 lines (41 loc) · 1.43 KB
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
# Condensed Version: Tkinter LASER WARS screensaver
# Python program example using variables.
# Created by Joseph C. Richardson, GitHub.com
from time import sleep as wait
from random import*
from tkinter import*
laser_wars = Tk()
laser_wars.title('Condensed Version: Tkinter LASER WARS')
everything = 'all'
def random_colour_code():
hex_chars = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f']
colour_code = '#'
for i in range(0,6):
colour_code = colour_code+choice(hex_chars)
return colour_code
colour = '#000000'
w,h = 1920,1080
r,c = 0,0
rand1,rand2 = 0,15
randint1,randint2 = -1920,1920
loop = 20
seconds = .08
laser_canvas = Canvas(laser_wars,width = w,height = h,background = colour)
laser_canvas.grid(row = r,column = c)
while True:
for i in range(loop): # increse the for loop value to add more lasers on the screen output
random_width = randint(rand1,rand2)
x = randint(randint1,randint2)
laser_canvas.create_line(
randint(randint1+x,randint2+x),
randint(randint1+x,randint2+x),
randint(randint1+x,randint2+x),
randint(randint1+x,randint2+x),
fill = random_colour_code(),
width = random_width)
laser_canvas.update()
wait(seconds)
laser_canvas.delete(everything)
laser_wars.mainloop()
# I am almost a complete Walking Human Computer Science Research
# Laboratory Machine on Two Legs...