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

Re: [pygame] circles



On Sat, Oct 2, 2010 at 8:09 PM, kevin hayes <kevinosky@xxxxxxxxx> wrote:
At this point I don't really care if the sprites write over eachother...
You should.  Because otherwise, you can't see anything.  I don't mean proper handling of occlusion; I mean not being able to see what's going on.  The problem can be found by first figuring out why they are being drawn on top of each other.  In graphics programming the problem is almost always self-evident once you see what's actually happening.
as long as that doesn't cause the program to crash.  I'm just trying to get four circles going diagonally from each corner.  The problem I'm having is with the update function...Do I write two update functions?  How do I get the update function to apply separate code for the two (or more) circles?
Only one update function can exist.  What you CAN (and should) do, though, is have the update function do a different thing for each sprite.  Your second update function is never getting called, so delete it. 
Here is my code as it stands:
Add this:
circle2.dx = -5
Then, you'll see that the sprites were being drawn over each other (and moreover, they were starting in the same position, so the yellow one darts off the screen to the left).  This latter is due to the fact that startPosx is never used.  Change your update function to change startPosx and startPosy instead of rect.center.
 
Ian