From the Super Mario Wiki
The goal of the game is to shake the capsule by tilting the console repeatedly until its color turns yellow. Once done so, what was put in it will have combined into something. If a monkey and a torch are put into the capsule, they will turn into a man. If a doll and a fish are put into the capsule, they will turn into a mermaid. If three dancers are out into the capsule, they will have made a pose by the time it opens.