this should get you going:
+ Code Snippet// Project: RockCoin
// Created: 2021-10-09
// By: Virtual Nomad
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "RockCoin" )
SetWindowSize( 1280,720, 0 )
SetWindowAllowResize( 1 )
// set display properties
SetVirtualResolution( 1280,720)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 )
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )
Yellow = MakeColor(255,255,0)
DrawEllipse(8,8,8,8,Yellow,Yellow,1)
GLOBAL CoinImg
Render()
CoinImg = GetImage(0,0,16,16)
Type Rock
ID, Coins, LastCoin#
EndType
GLOBAL Rocks as Rock []
For x = 0 to 4
ThisRock as Rock
ThisRock.ID = CreateSprite(0) : SetSpriteSize(ThisRock.ID,32,32)
SetSpritePositionByOffset(ThisRock.ID,300 + x*100.0,650)
SetSpritePhysicsOn(ThisRock.ID,1) : SetSpriteGroup(ThisRock.ID,-10)
ThisRock.Coins = (Random(2,5))
Rocks.InsertSorted(ThisRock)
Next x
Player = CreateSprite(0) : SetSpriteSize(Player,32,32)
SetSpritePositionByOffset(Player,200,700) : SetSpriteShapeCircle(Player, 0,0,16)
SetSpritePhysicsOn(Player,2)
SetSpritePhysicsCanRotate(Player,0)
SetPhysicsGravity(0.0,200)
do
PX# = GetSpriteXByOffset(Player) : PY# = GetSpriteYByOffset(Player)
Grounded = PhysicsRayCast( PX#,PY#,PX#,PY#+16.4)
If GetButtonState(1) and Grounded then Jump# = -200 else Jump# = GetSpritePhysicsVelocityY(Player)
If GetRawKeyState(27) then Exit
SetSpritePhysicsVelocity(Player, GetJoystickX()*150.0, Jump#)
If GetSpriteFirstContact(Player)
Repeat
ThisHit = GetSpriteContactSpriteID2()
If ThisHit > 0 and Rocks.Find(ThisHit) > -1
Rock = Rocks.Find(ThisHit)
If Rock > -1 and Rocks[Rock].Coins > 0 And Rocks[Rock].LastCoin# + 0.5 < Timer()
SpawnCoin(ThisHit)
Rocks[Rock].Coins = Rocks[Rock].Coins -1
Rocks[Rock].LastCoin# = Timer()
EndIf
EndIf
Until GetSpriteNextContact() = 0
EndIf
Print("[A/D]=Move, [W/D]=Climb, [Space]=Jump")
For x = 0 to Rocks.Length `Coins Left in Rock
Print(Rocks[x].Coins)
Next x
Sync()
loop
Function SpawnCoin(Spr)
ThisCoin = CreateSprite(CoinImg)
x = GetSpriteXByOffset(Spr) : y = GetSpriteY(Spr)
SetSpritePositionByOffset(ThisCoin, x,y-16)
SetSpriteGroup(ThisCoin,-10)
SetSpritePhysicsOn(ThisCoin,2)
SetSpriteShapeCircle(ThisCoin,0,0,8)
SetSpritePhysicsVelocity(ThisCoin,0,-100.0)
EndFunction

if you're doing a typical coin-spewing rock, you'll prolly want to make sure the contact made was with the player's head/upper body in order to spawn but i'll leave that up to you.