Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+8 votes

Lab 8 fish tank.

I can not figure out how to write a statement that makes the bubbles or the fish reappear on the other side of the window. I have tried a while statement in Bubble.move(), if statement, I even tried to redraw a shape to replace the one that left the window. How do I make these shapes "wrap around"?

asked in old_CSC201 by (1 point)

1 Answer

+1 vote

To make the bubble "wrap" from top to bottom, you ned to analyze the y coordinate of the bubble. If you have an instance variable circle, the you can access that y coordinate using

If that y coordinate would be above the top of the window, then you'll need to move the circle a large distance to move it just off the bottom of the window.

self.circle.move(0, WINDOW_HEIGHT + 5)

It is similar for the Fish class. Look at the x coordinate of the body of the fish compared to the right edge of the window. If the body of the fish has moved off the right edge, then move it a large distance left. In fact, move the body, tail, and eye a large distance left.

answered by (1 point)