[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Some problems with the pygame.draw.line function?



I'm working on some "fireworks-like" effect (nothing sophisticated though). 
One part of this effect is "shoot" - a line of some length, moving from the 
bottom of the screen to some point, with some speed. Very simple to code, 
as a matter of fact.

According to the Pygame docs, pygame.draw.line should return the Rect object 
describing the area affected by the drawn line. But I think, that in some 
cases it's not true. I use simple method of animation: draw the objects, 
update the screen, then clear all the affected areas (fill them with the 
background colour), and so on. My observations are clear: sometimes lines 
arent cleared properly and some "elements" remain on screen (because they 
aren't filled with the background colour). It happens, when the width of 
the "schoot" line is set to more than 1 (it should be set to 2 in my app, 
but I have experimented a little in order to find out what is going on). If 
the line width is set to 1, all works fine.

Besides, I tried to manually enlarge the Rect object returned by the 
pygame.draw.line function; instead of doing just:

-------------------------------------------
def show( self, surface ):
  return pygame.draw.line( surface, ... )
-------------------------------------------

I tried:

-------------------------------------------
def show( self, surface ):
  r = pygame.draw.line( surface, ... )
  r.width += 10
  r.height += 10
  r.top -= 5
  r.left -= 5
  return r
-------------------------------------------

And it worked (at least with the lines of the width equal to 2).

Is this some bug in the pygame.draw.line function, or perhaps in docs? Am I 
doing something wrong, or there's something I don't understand?


Best regards,

        Tomek