mirror of
https://github.com/d3vyce/Python-Game.git
synced 2025-04-02 20:03:22 +02:00
Add info text on screen
This commit is contained in:
parent
f2bc255a8a
commit
fdeff9e17f
@ -3,17 +3,35 @@ from pygame.locals import *
|
||||
|
||||
def init_game():
|
||||
pygame.init()
|
||||
pygame.font.init()
|
||||
screen = pygame.display.set_mode((1000, 525), pygame.SCALED)
|
||||
pygame.display.set_caption("Snake")
|
||||
|
||||
return screen
|
||||
|
||||
def draw_level(S, M, difficulty, score, heigh, width):
|
||||
def draw_level(S, M, difficulty, score, fps, heigh, width):
|
||||
WHITE = (255, 255, 255) # AIR
|
||||
GREEN = (0, 255, 0) # SNAKE
|
||||
BROWN = (255,248,220) # WALL
|
||||
RED = (255, 0, 0) # APPLE
|
||||
|
||||
# Reset screen
|
||||
pygame.draw.rect(S, (0, 0, 0), pygame.Rect(0, 0, 1000, 525))
|
||||
|
||||
my_font = pygame.font.SysFont('Comic Sans MS', 18)
|
||||
|
||||
# Add FPS counter
|
||||
text_fps = my_font.render(str(fps) + ' fps', False, (255, 255, 255))
|
||||
S.blit(text_fps, (10, 0))
|
||||
|
||||
# Add Score
|
||||
text_score = my_font.render('Score : '+ str(score), False, (255, 255, 255))
|
||||
S.blit(text_score, (400, 0))
|
||||
|
||||
# Add Diffucilty
|
||||
text_difficulty = my_font.render('Difficulty : '+ str(difficulty), False, (255, 255, 255))
|
||||
S.blit(text_difficulty, (850, 0))
|
||||
|
||||
Color = WHITE
|
||||
|
||||
for j in range(heigh):
|
||||
|
Loading…
x
Reference in New Issue
Block a user