From 38c27e03fbf48363c16a3f8d14032a88d22bf02a Mon Sep 17 00:00:00 2001 From: Adam Jurkiewicz Pythonista Local Date: Tue, 17 Mar 2026 13:43:08 +0100 Subject: [PATCH] pong - text --- dzien_01/d_04_pong.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dzien_01/d_04_pong.py b/dzien_01/d_04_pong.py index 6ee283f..f6587ed 100644 --- a/dzien_01/d_04_pong.py +++ b/dzien_01/d_04_pong.py @@ -13,13 +13,13 @@ sprite.x = WIDTH//2 sprite.y = HEIGHT//2 ship.x = randint(20,WIDTH-20) ship.y = randint(20,HEIGHT-20) -odleglosc = ship.distance_to(sprite) -def napis(): + +def napis(odleglosc): winner_txt = f"Odległość: {odleglosc} w pixelach" screen.draw.text( - winner_txt, (WIDTH // 3, 20), color="red", fontsize=60 + winner_txt, (5, 20), color="red", fontsize=60 ) # Najważniejsze funkcje sterujące def update(): @@ -46,6 +46,7 @@ def draw(): screen.blit("tomulus64.jpg", (0,0) ) ship.draw() sprite.draw() - napis() + odl = round(ship.distance_to(sprite), 1) + napis(odl) pgzrun.go() \ No newline at end of file