I'm learning to use pygame and I have some problems with rendering text.
The simplified code I'm working with is like this:
import pygame
sizex =200; sizey =200
pygame.init()
clock = pygame.time.Clock()
screen = pygame.display.set_mode((sizex,sizey))
myfont = pygame.font.Font(None, 32)
score=pygame.Rect(100,100,100,50)
screen.fill((255,255,255))
pygame.draw.rect(screen, (0,250,0), (10,10,10,10), 2)
pygame.display.update()
for i in xrange(0,1000):
msElapsed = clock.tick(2)
text="I = %d" %i
label = myfont.render(text, 1, (0,0,250))
screen.blit(label, (100, 100))
pygame.display.update(score)
I want update only the part of screen which contains the textbox. But this code is not doing this. The texts overwrite themselves and become unreadable after a while.
What am I doing wrong?