You already implement coins, so you probably understand how to make other collectables. If the question is about random, most common way to make it is randi()
function. randi()
generates random intager, so how you can use it?
Firstly, you should define probability of spawning object. Let's say that bricks drops nothing in 80% of chances, flover in 15% and mushroom in 5%. Take the modulo 100 and you'll get random int from 0 to 99. Then you can use if statement to spawn appropriate object. Like this:
var spawn_number = randi() % 100
if spawn_number < 15:
spawn_flower() #Make this function
elif spawn_number < 20:
spawn_mushroom() #And this too