Microsoft Small Basic

Program Listing: DCM180-0
bou = Shapes.AddRectangle(100, 20)
ball = Shapes.AddEllipse(20, 20)
score = 0

' チャンスは5回
For i=1 To 5
GraphicsWindow.DrawText(0,0, "5球のボールをマウスカーソルの左右でキャッチ")
x = Math.GetRandomNumber(GraphicsWindow.Width-20)
dest = 0
y = 0
' ボールが落ちてくる処理
While y < GraphicsWindow.Height-40
Shapes.Move( ball,x,y)
Shapes.Move( bou, GraphicsWindow.MouseX, GraphicsWindow.Height - 20 )
If(Math.GetRandomNumber(20)=1) Then
rnd = math.GetRandomNumber(2)
If(rnd = 2 And x > 0)then
dest = -2
EndIf
If (rnd = 1 And x+20 < GraphicsWindow.Width)then
dest = 2
EndIf
EndIf
x=x + dest
If(x<0)then
dest = 2
EndIf
If(x+20 > GraphicsWindow.Width) Then
dest = -2
EndIf
y=y+1
Program.Delay(5)
EndWhile

' とったかどうか判定
If( x >= Shapes.GetLeft(bou) And x <= Shapes.GetLeft(bou)+100 ) then
score = score + 1
EndIf
EndFor
GraphicsWindow.ShowMessage(score,"得点")