affichage des best score
This commit is contained in:
parent
4cbccef1f8
commit
8c6e5c55fa
|
@ -36,6 +36,13 @@ def __update(world: World):
|
|||
entity[Text] = writing.base_text
|
||||
if key.startswith("["): # pavé numerique
|
||||
key = key[1]
|
||||
match key:
|
||||
case "6":
|
||||
key = "-"
|
||||
case "8":
|
||||
key = "_"
|
||||
case _:
|
||||
pass
|
||||
if key in writing.accepted_chars and (
|
||||
entity[Text] == writing.base_text
|
||||
or len(entity[Text]) < writing.max_chars
|
||||
|
|
|
@ -18,12 +18,12 @@ import requests as rq
|
|||
IP = "pong.cocosol.fr"
|
||||
|
||||
|
||||
def get_scores():
|
||||
def get_scores() -> list[tuple[int, str]]:
|
||||
try:
|
||||
return rq.get(f"https://{IP}/data").json()
|
||||
except:
|
||||
print("Error with the serveur")
|
||||
return ["", 1]
|
||||
return [(1, "")]
|
||||
|
||||
|
||||
def __create_button(world: World, i: int, name: str):
|
||||
|
@ -33,7 +33,7 @@ def __create_button(world: World, i: int, name: str):
|
|||
world.new_entity().set(
|
||||
SpriteBundle(
|
||||
f"button_{name}.png",
|
||||
position=Vec2(450 + 540 * i, render.HEIGHT / 2),
|
||||
position=Vec2(450 + 540 * i, 11 * render.HEIGHT / 16),
|
||||
order=1,
|
||||
origin=Vec2(0.5),
|
||||
),
|
||||
|
@ -79,12 +79,22 @@ def __spawn_score(world: World):
|
|||
"""
|
||||
Ajoute le score dans le monde.
|
||||
"""
|
||||
for i, score in enumerate(get_scores()):
|
||||
print(get_scores())
|
||||
for i, (score, name) in enumerate(get_scores()):
|
||||
world.new_entity().set(
|
||||
TextBundle(
|
||||
score[1] + " : " + str(score[0]),
|
||||
position=Vec2(render.WIDTH / 2, 350 + 50 * i),
|
||||
origin=Vec2(0.5),
|
||||
f"{name}",
|
||||
position=Vec2(render.WIDTH / 2 - 350, 325 + 50 * i),
|
||||
origin=Vec2(0),
|
||||
order=1,
|
||||
)
|
||||
)
|
||||
|
||||
world.new_entity().set(
|
||||
TextBundle(
|
||||
f"{score}",
|
||||
position=Vec2(render.WIDTH / 2 + 350, 325 + 50 * i),
|
||||
origin=Vec2(1, 0),
|
||||
order=1,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -63,7 +63,7 @@ def __spawn_elements(world: World):
|
|||
),
|
||||
Writing(
|
||||
"azertyuiopqsdfghjklmwxcvbn0123456789_-/",
|
||||
10,
|
||||
16,
|
||||
"...",
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue