-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscrap_bench.py
More file actions
executable file
·58 lines (48 loc) · 1.26 KB
/
Copy pathscrap_bench.py
File metadata and controls
executable file
·58 lines (48 loc) · 1.26 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
55
56
57
58
#!/usr/bin/env python3
import os
import random
import time
import scrap_engine as se
def main():
global avr, tcount
os.system("")
b_map = se.Map(background=" ")
text = se.Text("0")
avr = se.Text("0")
rectangle = se.Square("\033[34ma\033[0m", 50, 10)
text.add(
b_map,
round((b_map.width - len(text.text)) / 2 - 10),
round(b_map.height / 2) - 1,
)
avr.add(
b_map,
round((b_map.width - len(text.text)) / 2 - 10),
round(b_map.height / 2),
)
rectangle.add(b_map, 0, 0)
tcount = 0
times = 0
time2 = 0
b_map.show()
while True:
time0 = time.time()
times += time2
for ob in rectangle.obs:
ob.set(
random.choice([ob.x, ob.x + 1, ob.x - 1]),
random.choice([ob.y, ob.y + 1, ob.y - 1]),
)
text.rechar(str(time2))
avr.rechar(str(times / tcount if tcount != 0 else 1))
b_map.show()
tcount += 1
time2 = time.time() - time0
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print(f"""KeyboardInterrupt
Screen size: {se.screen_width}x{se.screen_height}
Average frame time: {avr.text}s
Frames drawn: {tcount}""")