Hi.
I want make a side scrolling game and for this work I made a coin (like Arrow). now I want randomly show it in (x,y) Position.
this is my code also attached coin image, Please Guide Me how can Randomly show it.
SetDisplayAspect( 4.0/3.0 )
global CoinImg as Integer
global CoinEmptySprite as Integer
global dim CoinSpr[9]
global create = 0
global move# = 0.5
do
Time# = Timer()
Print (Time#)
SetViewOffset(GetViewOffsetX()+move#,GetViewOffsetY())
if Time# > 5
CreateCoin()
ResetTimer()
endif
Sync()
loop
/////////////////////////////////////Functions
Function CreateCoin()
CoinImg = LoadIMage("coin.png")
CoinEmptySprite = CreateSprite(0)
SetSpriteVisible(CoinEmptySprite,0)
for a = 1 to 9
if GetSpriteExists(CoinSpr[a]) = 0 then CoinSpr[a] = CloneSprite(CoinEmptySprite)
SetSpriteVisible(CoinSpr[a],1)
SetSpriteSize(CoinSpr[a],5,-1)
Select a
case 1:
SetSpriteImage(CoinSpr[1],CoinImg)
SetSpritePosition(CoinSpr[1],50+GetViewOffsetX()+50,50)
endcase
case 2:
SetSpriteImage(CoinSpr[2],CoinImg)
SetSpritePosition(CoinSpr[2],46+GetViewOffsetX()+50,46)
endcase
case 3:
SetSpriteImage(CoinSpr[3],CoinImg)
SetSpritePosition(CoinSpr[3],54+GetViewOffsetX()+50,54)
endcase
case 4:
SetSpriteImage(CoinSpr[4],CoinImg)
SetSpritePosition(CoinSpr[4],50+GetViewOffsetX()+50,57.5)
endcase
case 5:
SetSpriteImage(CoinSpr[5],CoinImg)
SetSpritePosition(CoinSpr[5],46+GetViewOffsetX()+50,61)
endcase
case 6:
SetSpriteImage(CoinSpr[6],CoinImg)
SetSpritePosition(CoinSpr[6],45+GetViewOffsetX()+50,53.5)
endcase
case 7:
SetSpriteImage(CoinSpr[7],CoinImg)
SetSpritePosition(CoinSpr[7],40+GetViewOffsetX()+50,53.5)
endcase
case 8:
SetSpriteImage(CoinSpr[8],CoinImg)
SetSpritePosition(CoinSpr[8],35+GetViewOffsetX()+50,53.5)
endcase
case 9:
SetSpriteImage(CoinSpr[9],CoinImg)
SetSpritePosition(CoinSpr[9],30+GetViewOffsetX()+50,53.5)
endcase
EndSelect
Next a
EndFunction