[pyGame] More Text in one Window, example needed ! - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Game Development (https://python-forum.io/forum-11.html) +--- Thread: [pyGame] More Text in one Window, example needed ! (/thread-5432.html) |
[pyGame] More Text in one Window, example needed ! - JamieVanCadsand - Oct-03-2017 Hey Game Developers... I try to create more tekst fonts in one game window, in one script... But it don't works... This is my script: from datetime import datetime import pygame import sys pygame.init() size = (640, 480) screen = pygame.display.set_mode(size) pygame.display.set_caption("Clock") WHITE = (255, 255, 255) GREEN = (0, 255, 0) done = False clock = pygame.time.Clock() while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: done = True screen.fill(WHITE) now = datetime.now() font1 = pygame.font.SysFont('Calibri', 25, True, False) text1 = font.render('Sec: ' + str(now.second), True, GREEN) screen.blit(text1, [320, 240]) font2 = pygame.font.SysFont('Calibri', 25, True, False) text2 = font.render('Min: ' + str(now.minute), True, GREEN) screen.blit(text2, [320, 230]) font3 = pygame.font.SysFont('Calibri', 25, True, False) text3 = font.render('Hou: ' + str(now.hour), True, GREEN) screen.blit(text3, [320, 220]) pygame.display.flip() clock.tick(60) pygame.quit() sys.exit()Pygame don't run my game perfect, my screen is black... please whats wrong with my code ?... Can anyone give my an example code to lost this problem ?... Thanks, Jamie. RE: [pyGame] More Text in one Window, example needed ! - metulburr - Oct-03-2017 If i run your script i get this error You seemed to copy and paste each line and forgot to change font{NUM}font1 = pygame.font.SysFont('Calibri', 25, True, False) text1 = font1.render('Sec: ' + str(now.second), True, GREEN) screen.blit(text1, [320, 240]) font2 = pygame.font.SysFont('Calibri', 25, True, False) text2 = font2.render('Min: ' + str(now.minute), True, GREEN) screen.blit(text2, [320, 230]) font3 = pygame.font.SysFont('Calibri', 25, True, False) text3 = font3.render('Hou: ' + str(now.hour), True, GREEN) screen.blit(text3, [320, 220]) |