Now, here's exactly how your project works based on what you've built:
Your Sprites: You have 3 elements — the Stage (underwater background), Yellow Fish (the food/bait that spawns), and Shark 011 (the shark that chases the mouse).
Yellow Fish Code Breakdown:

On Start (Left Stack): The score is set to 0 when the game begins. The Yellow Fish is hidden at first, its size is set to 30%, and then a forever loop runs. Inside the loop, it teleports to x: -230 with a random y value between 180 and -180 (so it spawns at random heights on the left side). It then creates a clone of itself, waits 1 second, and switches costume — this means multiple fish keep spawning every second from the left edge.
Clone Startup (Right Stack): Each clone becomes visible, points in direction 90 (facing right), and enters a forever loop. Inside that loop, it turns a random amount between -10 and 10 degrees each step, moves 5 pixels, and bounces off edges. The rotation style is set to left-right so the fish flips properly. Then comes the key part — if the clone is touching Shark 011, the score increases by 1, a "chomp" sound plays, it broadcasts the message "Food," and the clone hides (disappears). This is how the shark "catches" the fish.
Shark 011 Code Breakdown:
On Start (Left Stack): The shark starts with costume "Shark 13," is set to 100% size, and enters a forever loop. It points towards the mouse pointer at all times, uses left-right rotation style so it flips correctly, and if the distance to the mouse pointer is greater than 10, it moves 10 pixels toward it. This makes the shark smoothly follow your cursor around the screen.
When I Receive "Food" (Right Stack): This is the eating animation. When the shark catches a fish (triggered by the "Food" broadcast), it repeats 3 times: it switches between costume "Shark 08" and "Shark 12" with 0.1 second waits in between — creating a mouth-opening and closing animation. It also changes the color effect by 25 each time, giving a visual flash. After the animation finishes, it clears all graphic effects to return to normal.
How the Game Works Together: Fish spawn on the left and drift rightward with slight random direction changes. The shark follows your mouse. When you guide the shark into a fish, it gets eaten, the score goes up, the shark does a chomp animation with a color flash, and the fish disappears. New fish keep spawning continuously, so the game loops on its own.


Comments
Post a Comment