-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfallout.py
134 lines (111 loc) · 2.7 KB
/
fallout.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from hw import *
from kandinsky import *
from ion import *
from math import ceil,floor
from random import randint
import time
SETTINGS={
"CHARACTERS": "".join([
(alphabet:="ABCDEFGHIJKLMNOPQRSTUVWXYZ")+alphabet.lower(),
#"".join([str(e) for e in list(range(10))]),
" " * 20,
]),
"FIZZLE": False,
"SPEED": 1/2,
"COLOR": [96]*3,
}
FIELDS={
(1,2):{
"name": "Time",
"data": time.monotonic(),
},
(2,3):{
"name": "Battery",
"data": str(
floor(battery_level()*10**3)/10
)[:4]+"%",
},
#():{
# "name": "Memory",
# "data": str(),
#},
}
def genLine(chars:"",length:int):
return "".join([
chars[randint(0,len(chars)-1)]
for x in range(length)
])
str_array = [
genLine(SETTINGS["CHARACTERS"], ceil(scrW/chrW))
for y in range(scrH//chrH+2)
]
def settings():
pass
scroll=0
def upd():
global str_array,scroll
scroll += SETTINGS["SPEED"]
if scroll%chrH==0:
scroll=0
str_array=[genLine(
SETTINGS["CHARACTERS"],
ceil(scrW/chrW),
)] + str_array[scroll//chrH:]
for y,string in enumerate(str_array):
if SETTINGS["FIZZLE"]: y-=1
str_pos=randint(0,len(string)-1)
str_array[y] = (
string[:str_pos] +
SETTINGS["CHARACTERS"][randint(0,len(SETTINGS["CHARACTERS"])-1)] +
string[str_pos+1:]
)
if not SETTINGS["FIZZLE"]: y-=1
abs_pos=y * chrH + scroll
print(string)
for x,chr in enumerate(string):
field=FIELDS.get((x,y),None)
if field is None: continue
string=[
string[:x],
[(bit:=f" {field["name"]}: {field["data"]} ")],
string[x+len(bit):len(string)],
#print(len(string),len(bit))
]
if type(string) is str: string=[string]
print(string)
str_width=0
for b,bit in enumerate(string):
escape_fade=False
if type(bit) is list:
bit=bit[0]
string[b]=bit
escape_fade=True
str_width+=len(bit)
#print(sum([len(s) for s in string[:b]]))
draw_string(
bit,
chrW*(sum([len(s) for s in string[:b]])),
floor(abs_pos),
get_palette()["PrimaryText"] if escape_fade else [max(channel,
SETTINGS["COLOR"][idx] - ceil(
max(abs_pos,0)/scrH*(
SETTINGS["COLOR"][idx] - channel
)
))
for idx,channel in enumerate(get_palette()["HomeBackground"])],
)
y+=1
"""
for field in FIELDS:
draw_string(
f"{field["name"]}: {field["data"]}",
field["pos"][0],
field["pos"][1],#+floor(scroll),
)
"""
FPS_CAP=70
while True:
upd()
#draw_string(str(FPS_CAP),0,0)
#FPS_CAP+=keydown(KEY_RIGHT)-keydown(KEY_LEFT)
time.sleep(1/FPS_CAP)