Boom thank you so much

I was ignore both command.

More knowledge on the way
[/quote] i've changed this thread's title to something a bit more helpful for Search purposes.[quote=]
Perfect!! Is much better so maybe the topic cap help someone else too
The random2() work perfectely

I feel happy about this small test/project, is a very very very simple mini-game but have same basic stuff in it, now i can carry one to discover more stuff, guides and tutorial! And start to use arrays...
Thank You again
Complete:
// Project: 01 SHARKDOG : Created: 2020-09-14
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SetOrientationAllowed(0,0,1,1) : UseNewDefaultFonts(1)
Shark=2 : Wow=3 : Back=4 : World=5 : Logo=6 :Score=0 : HiScore=0 : Gameover=1 : Neon=10 //Neon= SharkDog logo by https://cooltext.com/
Crunch=LoadSound("Crunch.wav") : LoadMusicOGG(1,"Deadpool.ogg") //Crunch sound by https://freesound.org/
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LoadImage(1,"Hdog.png") :
LoadImage(2,"Shark.png") : CreateSprite(Shark,2) : SetSpriteDepth(Shark,2)
//LoadImage(3,"Wow.png") : //CreateSprite(Wow,3) : SetSpriteDepth(Wow,1) : SetspriteVisible(Wow,0)
LoadImage(4,"Back.png") : CreateSprite(Back,4) : SetSpriteDepth(Back,5) : SetSpriteColor(Back,0,255,255,200)
LoadImage(5,"World.png") : CreateSprite(World,5) : SetSpriteDepth(World,4)
LoadImage(6,"Logo.png") : LoadImage(10,"Neon.png")
Px=GetDeviceWidth()/3 : Py=GetDeviceHeight()/3
SetPhysicsWallTop(1)
SetPhysicsWallBottom(1)
SetPhysicsWallLeft(1)
SetPhysicsWallRight(1)
Hmax=0
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
do
//////////////////////////////////////////// Resolution
W=GetDeviceWidth() : H=GetDeviceHeight() : SetVirtualResolution (W,H)
//////////////////////////////////////////// Sprite
SetSpriteSize(Shark,W/4,H/4) : SetSpriteSize(Wow,W/6,H/6) : SetSpriteSize(Back,W,H) : SetSpriteSize(World,H,H)
SetSpritePosition(World,W/2+H/10,H/2-H/8)
//////////////////////////////////////////// Player Move
SetJoystickScreenPosition(GetDeviceHeight()/2-GetDeviceHeight()/4,GetDeviceHeight()/4+GetDeviceHeight()/2,GetDeviceHeight()/6)
SetSpritePosition(Shark,Px,Py) : Px=Px+GetJoystickX()*10 : Py=Py+GetJoystickY()*10
//////////////////////////////////////////// Physics Player
SetSpritePhysicsOn(Shark,2)
SetSpriteShape(Shark,3)
////////////////////////////////////////////
gosub Limit_Hdog
gosub Collision
gosub Player
if GetSpriteCollision(Hdog,Bar)=1
DeleteSprite(Bar)
DeleteSprite(Hdog)
gameover=1
Hmax=0
endif
if gameover=1
StopMusicOGG(1)
gosub MainMenu
score=0
endif
SetTextString(1,"HighScore: "+str(HiScore))
Print("Score: "+str(Score)) : Print("HiScore: "+str(HiScore))
Sync()
loop
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit_Hdog:
if gameover=0
if Hmax<1
Whx=W/8
Why=H/8
Hdog= CreateSprite(1) : SetSpriteSize(Hdog,Whx,Why) : SetSpriteDepth(Hdog,2)
Hx=random2(1,W-Whx)
Hy=random2(1,H-Why)
SetSpritePosition(Hdog,Hx,Hy)
SetSpritePhysicsOn(Hdog,2)
SetSpriteShape(Hdog,3)
Hmax=1
endif
endif
Return
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Collision:
if GetSpriteCollision(Shark,Hdog) = 1
PlaySound(Crunch)
Score=Score+1
if Score>HiScore
HiScore=Score
endif
Hmax=0
DeleteSprite(Hdog)
endif
Return
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Player:
if Px<0
Px=0
endif
if Px>GetVirtualWidth()-(GetSpriteWidth(Shark))
Px=GetVirtualWidth()-(GetSpriteWidth(Shark))
endif
if Py<0
Py=0
endif
if Py>GetVirtualHeight()-(GetSpriteHeight(Shark))
Py=GetVirtualHeight()-(GetSpriteHeight(Shark))
endif
SetSpritePosition(Shark,Px,Py)
Return
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
MainMenu:
Back2=7
Createsprite(Back2,4) : SetSpriteSize(Back2,GetDeviceWidth(),GetDeviceHeight()) : SetSpriteColorAlpha(Back2,85)
Createsprite(Logo,6) : SetSpriteSize(Logo,GetDeviceWidth(),GetDeviceHeight())
Createsprite(Neon,10)
SetSpriteSize(Neon,W/3,H/3)
SetSpritePosition(Neon,GetSpriteWidth(Neon)/2,GetDeviceHeight()-GetSpriteHeight(Neon))
CreateText(1,"HighScore: "+str(HiScore))
SetTextColor(1,0,255,0,255)
SetTextSize(1,125)
SetTextPosition(1,W/2,H/2-H/6)
gosub HideGameSprite
gosub ShowMenuText
repeat
sync()
until GetPointerPressed()=1
gameover=0
PlayMusicOGG(1,1)
gosub ShowGameSprite
gosub HideMenuText
gosub CheckGameOver
Return
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HideGameSprite:
for i=1 to 5
SetSpriteVisible(i,0)
next i
Return
//
ShowGameSprite:
for i=1 to 5
SetSpriteVisible(i,1)
next i
Return
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ShowMenuText:
SetTextVisible(1,1)
SetSpriteVisible(Back2,1) : SetSpriteVisible(Logo,1) : SetSpriteVisible(Neon,1)
Return
//
HideMenuText:
SetTextVisible(1,0)
SetSpriteVisible(Back2,0) : SetSpriteVisible(Logo,0) : SetSpriteVisible(Neon,0)
Return
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CheckGameOver:
if gameover=0
bar=8
CreateImageColor(7,255,0,0,0)
CreateSprite(Bar,7) : SetSpriteDepth(Bar,2)
Setspritesize(Bar,W,H/100)
SetSpritePosition(Bar,0,H-GetSpriteHeight(Bar))
DeleteSprite(Hdog)
gosub Limit_Hdog
endif
Return
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------