Page 1 of 1

Help with Python (Pygame)

Posted: Sun Oct 28, 2012 9:20 pm
by jajasuperman
Hi all!!!
I´m developing a little game using Python with the Pygame library.
The game has 3 object, one ball ( that is moving around the screen), one square and another square (we control this square using the mouse).
I would like to do this: When you collect the square should appear another ball, but not in the same coordinates.
How I can do?
Thanks.
PD: Sorry with my English, I´m from Spain.

Re: Help with Python (Pygame)

Posted: Thu Dec 20, 2012 2:48 pm
by svenn
When the mouse coordinates hit the object, you should destroy it, and generate another object at random (x,y) position. To move an object and not draw on top of it, you should redraw the frame.

Code: Select all

while True :
if (check_for_collision(x, y)) :
redraw_screen();
generate_ball();
draw_ball(x,y);
collisions++;

if(collisions > 5)
exit;