File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change 1111import time
1212import os
1313import random
14- random .seed ()
15- refreshRate = 0.3
16- X = 17
17- Y = 7
18- tablica = [- 1 ];
14+ refreshRate = 0.3 #co ile odświeżamy
15+ X = 80 #wymiar X
16+ Y = 23 #wymiar Y
17+ tablica = [- 1 ]; #gdzie znajdująsię krople
1918
2019
2120def display ():
22- for y in range (Y ):
23- for x in range (X ):
24- if (x in tablica and tablica .index (x ) == y ):
21+ for y in range (Y ): #przechodzimy przez kolejne rzędy
22+ for x in range (X ): #i kolejne komórki w nich
23+ if (x in tablica and tablica .index (x ) == y ): #jeśli w naszej tablicu znajdziemy x i jego pozycja odpowiada y
2524 print ("o" , end = '' )
2625 else :
2726 print ("." , end = '' )
@@ -30,18 +29,19 @@ def display():
3029
3130
3231def randomDrop ():
33- d = tablica [0 ];
32+ d = tablica [0 ];# pobieramy element z tablicy
3433 while (d in tablica ):
3534 d = random .randint (0 ,X - 1 ) #znajdz mijsce nie zajęte przez kroplę
3635
3736 tablica .insert (0 ,d )
3837 if (len (tablica ) > Y ):
3938 tablica .pop () # usuń kroplę, poza widokiem
40-
39+
40+ random .seed ()# ustawiamy generator liczb losowych
4141while ( True ):
42- randomDrop ()
43- display ()
44- time .sleep (refreshRate )
45- os .system ('clear' );
42+ randomDrop ()#losjemy nową kroplę
43+ display ()#wyświetl klatę deszczu
44+ time .sleep (refreshRate )#poczekaj
45+ os .system ('clear' );#wyczyść terminal
4646
4747
You can’t perform that action at this time.
0 commit comments