Your code looks good to me.

I would in all honesty in your main DO LOOP, is have functions only in order.

i.e

setupdisplay()
setupvariables()
initialiseship()
// main loop
Do
checkkeypresses()
moveship()
displayship()
Sync()
Loop
function setupdisplay()
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle(" Area 51 ")
SetWindowSize(1024,768,0)
// set display properties
SetVirtualResolution(1024,768)
SetDisplayAspect(4.0/3.0)
SetOrientationAllowed(0,0,1,1)
SetWindowAllowResize(1)
SetSyncRate(60,0)
SetScissor(0,0,0,0)
endfunction
function setupvariables()
// deklarace
Global x#,y#,speed#
Global s1,s2,h1,h2
h1=1:h2=10
speed#=3.1
x#=50:y#=300
endfunction
function initialiseship()
// ship
For i=1 To 17
CreateSprite(i,LoadImage("ship"+Str(i)+".png"))
SetSpriteVisible(i,0)
SetSpriteDepth(i,20)
Next i
SetSpriteVisible(1,1)
endfunction
function checkkeypresses()
// pohyb X
If GetRawKeyState(39) And x#<900
x#=x#+speed#
ElseIf GetRawKeyState(37) And x#>0
x#=x#-speed#
EndIf
// pohyb Y
If GetRawKeyState(40) And y#<665
y#=y#+speed#
Inc s1
ElseIf GetRawKeyState(38) And y#>10
y#=y#-speed#
Inc s2
Else
s1=0:s2=0
If h1>1 Then Dec h1
If h2>9 Then Dec h2
EndIf
endfunction
function moveship()
// řízení naklápění lodi
// dolů
If s1>1
Inc h1
s1=0
If h1>9 Then h1=9
If h2>9 Then Dec h2
EndIf
If h1>1
For i=2 To 9
SetSpriteVisible(i,0)
Next i
SetSpriteVisible(h1,1)
EndIf
// nahoru
If s2>1 And h2<17
Inc h2
s2=0
EndIf
If h2>9
For i=10 To 17
SetSpriteVisible(i,0)
Next i
SetSpriteVisible(h2,1)
EndIf
endfunction
function displayship()
// ship
For i=1 To 17
SetSpritePosition(i,x#,y#)
Next i
endfunction

Something along those lines,

This to me is personal choice, much cleaner and easier to find and read code

Damo

Using Tier 1 AppGameKit V2

Started coding with AMOS

Anything is possible if put mind to it