Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+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 (8 points)

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
self.circle.getCenter().getY()

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 (8 points)
...