Lesson 28 Final Project Design a game

When the student uses the fish to press on the food, the food will bounce off the edge once or twice and then go completely off the screen. We want the fish food to stay on the screen and not go off the screen which is why he created Edges. Why is the food flying off the screen?

from my theory it’s the uncapped velocity your allowing to happen

food.velocityX = Math.min(18, food.velocityX);
food.velocityY = Math.min(18, food.velocityY);

using this should be a simple solution