When Wario took over Mario's castle, he assigned each of his generals to guard a golden coin, all six of which Mario needs to enter the castle. Ricky guarded the coin in the Macro Zone. Mario fought him and defeated him. After the maniacal hamster was destroyed, Mario took the coin.
To defeat Ricky, Mario must jump on him three times. Ricky will run into a pipe, then come out of another pipe. He can also climb up the wall and walk on the ceiling. He will usually fall down near the middle of the screen. He will always come out of the pipe he entered.