This is the function mousePressed()
, right?
You are using splice, but this is for joining two arrays afaik
Do you want to add a fish? Try push() maybe?
see Array.prototype.push() - JavaScript | MDN
(see also reference | p5.js)
You can check the 2 fishs in mousePressed() also, without a for-loop, so simply after the for-loop.
If they are clicked set a boolean (hasBeenClicked) inside the class to true. It is initially false.
Now when displaying the fishs, check if hasBeenClicked is false or true.
-
If it’s false display the fishs traditionally.
-
If it’s true, display the fishs in the other, small aquarium. (“store” them for further use in the small aquarium)
Warm regards,
Chrisir