Advertising (This ad goes away for registered users. You can Login or Register)

Help with Python (Pygame)

Programming on your favorite platform, for your favorite platform? Post here
Post Reply
jajasuperman
Posts: 1
Joined: Thu Aug 30, 2012 1:02 pm

Help with Python (Pygame)

Post by jajasuperman » Sun Oct 28, 2012 9:20 pm

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.
Advertising

svenn
Posts: 66
Joined: Fri Dec 24, 2010 5:17 pm
Location: Belgium
Contact:

Re: Help with Python (Pygame)

Post by svenn » Thu Dec 20, 2012 2:48 pm

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;
Advertising

Post Reply

Return to “Programming”