aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerberdes@gmx.com>2019-05-12 11:00:08 +0200
committerLoic Guegan <manzerberdes@gmx.com>2019-05-12 11:00:08 +0200
commitdf0fcb5952475f1ab7d414884163b410c7fe9c94 (patch)
tree761bf6636eacd8d5465b2ba5615f7b74cf48da67
parentbbd9151d7fa3500582c62474da2ce39ea151a63c (diff)
Add score
-rw-r--r--client/client.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/client/client.py b/client/client.py
index ea72c27..7bded0e 100644
--- a/client/client.py
+++ b/client/client.py
@@ -42,7 +42,7 @@ LARGEUR_ECRAN = LARGEUR_BLOCK * NB_BLOCKS
pygame.init()
ecran = pygame.display.set_mode((LARGEUR_ECRAN,LARGEUR_ECRAN))
-
+myfont = pygame.font.SysFont('Comic Sans MS', 20)
snakeSprite = pygame.image.load("snake-sprite.png").convert_alpha()
snakeSprite = pygame.transform.scale(snakeSprite, (LARGEUR_BLOCK, LARGEUR_BLOCK))
@@ -78,11 +78,12 @@ def main():
gameInit = newGame()
gameId = gameInit['ID']
up = gameInit
-
+ initSize=len(up['SNAKE'])
continuer = True
while continuer:
afficher(ecran, up['SNAKE'], up['FOOD'])
+ ecran.blit(myfont.render('Score {}'.format(len(up['SNAKE'])-initSize), False, (0, 0, 0)),(0,0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
continuer = False
@@ -92,7 +93,7 @@ def main():
if updateTmp != None and 'TYPE' in updateTmp:
if updateTmp['TYPE'] != 'error':
up = updateTmp
-# time.sleep(0.2)
+ time.sleep(0.3)
pygame.display.flip()
up = update(gameId)