A9 Fertig

This commit is contained in:
Chrissi 2026-06-11 14:02:49 +02:00
parent 4da36feccc
commit 16fe3639ed
7 changed files with 34 additions and 6 deletions

3
.vscode/settings.json vendored Executable file
View File

@ -0,0 +1,3 @@
{
"python-envs.defaultEnvManager": "ms-python.python:system"
}

0
A9/arbeitsblatt9.pdf Normal file → Executable file
View File

7
A9/highscores.txt Normal file → Executable file
View File

@ -1,6 +1,5 @@
30#2020-06-11 18:34:26#
20#2020-06-11 19:08:10#
10#2020-06-11 19:08:21#
0#2020-06-11 19:11:14#
1230#2026-06-09 22:33:50#
70#2020-06-11 19:08:56#
50#2020-06-11 19:09:25#
30#2020-06-11 18:34:26#
20#2026-06-11 09:54:46#

0
A9/ohm.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

27
A9/pong-oo-highscore-aufgabe.py Normal file → Executable file
View File

@ -105,14 +105,37 @@ class Highscore(GameObject):
self.scores = {}
self.last_score = None
### TODO: Hier müssen die Highscores eingelesen werden
##Falls es noch keine Highscore.txt gibt##
# try:
# with open("A9/highscores.txt", "r") as file:
# for line in file:
# parts = line.split("#")
# score = int(parts[0])
# time = parts[1]
# self.scores[score] = time
# except:
# pass
with open("A9/highscores.txt", "r") as file:
for line in file:
parts = line.split("#")
score = int(parts[0])
time = parts[1]
self.scores[score] = time
def signal_is_over(self, game_objects):
self.last_score = game_objects[OBJ_COUNTER].counter
self.scores[self.last_score] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
### TODO: Hier müssen die Highscores gesichert werden
with open("A9/highscores.txt", "w") as file:
sorted_scores = sorted(self.scores.keys())
sorted_scores.reverse()
for score in sorted_scores[:5]:
time = self.scores[score]
file.write(f"{score}#{time}#\n")
self.visible = True

0
README.md Normal file → Executable file
View File

3
highscores.txt Executable file
View File

@ -0,0 +1,3 @@
30#2026-06-09 22:30:54#
10#2026-06-09 22:31:03#
0#2026-06-09 22:31:09#