tags:

views:

115

answers:

2

I have an application written in python that's basically an etch-a-sketch, you move pixels around with WASD and arrow keys and it leaves a trail. However, I want to add a counter for the amount of pixels on the screen. How do I have the counter update without updating the entire surface and pwning the pixel drawings?

+1  A: 

Here

Rigo Vides
A: 

Use Surface.blit(source, dest, area=None, special_flags = 0): return Rect

dest can be a pair of coordinates representing the upper left corner of the source.

You probably want to erase the your old counter value, before you blit the new one. For this you can capture the background before you blit your counter value for the first time. Then blit that image everytime before you update the counter value.

In addition you should make the background of surface that your blitting transparent. Assuming you have black font on white background, you could use:

source.set_colorkey((255,255,255))
Ralph