Microsoft Small Basic

Program Listing: PGR013
GraphicsWindow.Width = 700
GraphicsWindow.BackgroundColor = "blue"
GraphicsWindow.Height = 400
GraphicsWindow.BrushColor = "red"
GraphicsWindow.Title = "Ball bounce"
GraphicsWindow.DrawLine(250,350,300,350)
GraphicsWindow.DrawLine(300,300,350,300)
GraphicsWindow.DrawLine(330,250,380,250)
GraphicsWindow.DrawLine(250,180,280,180)
GraphicsWindow.DrawLine(250,110,280,110)
GraphicsWindow.DrawLine(360,100,380,100)
ball = Shapes.AddEllipse(10,10)
line = Shapes.AddLine(d,100,f,100)
GraphicsWindow.KeyDown = KeyPress
GraphicsWindow.KeyUp = Keyup
Sub KeyPress
key = GraphicsWindow.LastKey
EndSub
Sub Keyup
keyup = GraphicsWindow.LastKey
EndSub
x = 200
y = 390
d = 360
f = 380
d1 = .3
f1 = .3
dy = - 1
GraphicsWindow.ShowMessage("Right arrow is right-the left arrow is left-and the up arrow is stop moving sideways." , "ball bounce")
Sound.PlayChimesAndWait()
start:
Program.Delay(3)
x = x + dx
y = y + dy
f = f + f1
d = d + d1
Shapes.Move(ball, x,y)
Shapes.Move(line, d,f)
dy = dy + .005
If (y > 390) Then
dY = - 1
EndIf
If (f > 700) Then
d1 = d1 - d1
f1 = f1 - f1
endif
If (x > 250 And y > 340 And y < 341 And x < 300 And dy > 0) Then
dy = - 1
Sound.PlayClick()
l = 1
EndIf
If (x > 290 And y > 290 And y < 291 And x < 340 And dy > 0) Then
dy = - 1
Sound.PlayClick()
EndIf
If (x > 330 And y > 240 And y < 241 And x < 380 And dy > 0) Then
dy = - 1
Sound.PlayClick()
EndIf
If (x > 250 And y > 170 And y < 171 And x < 280 And dy > 0) Then
dy = - 1
Sound.PlayClick()
EndIf
If (x > 250 And y > 100 And y < 101 And x < 280 And dy > 0) Then
dy = - 1
Sound.PlayClick()
EndIf
If (x > 360 And y > 90 And y < 91 And x < 380 And dy > 0) Then
dy = - 1
Sound.PlayClick()
EndIf
If (key = "Right") Then
dx = .3
EndIf
If (key = "Left") Then
dx = - .3
EndIf
If (key = "Up") Then
dx = 0
EndIf
If (y > - 5) Then
Goto start
EndIf
GraphicsWindow.ShowMessage("You win!!", "ball Bounce")



GraphicsWindow.Clear()
A = 250
A1 = 350
A2 = 300
GraphicsWindow.DrawLine(300,300,350,300)
GraphicsWindow.DrawLine(330,250,380,250)
GraphicsWindow.DrawLine(250,180,280,180)
GraphicsWindow.DrawLine(250,110,280,110)
GraphicsWindow.DrawLine(360,100,380,100)
ball = Shapes.AddEllipse(10,10)
GraphicsWindow.KeyDown = KeyPress2
Sub KeyPress2
key = GraphicsWindow.LastKey
EndSub
x = 200
y = 390
d = 360
f = 380
d1 = .3
f1 = .3
dy = - 1
GraphicsWindow.ShowMessage("Right arrow is right-the left arrow is left-and the up arrow is stop moving sideways." , "ball bounce")
start2:
Program.Delay(2.5)
x = x + dx
y = y + dy
f = f + f1
d = d + d1
Shapes.Move(ball, x,y)
Shapes.Move(line, d,f)
dy = dy + .005
If (y > 390) Then
dY = - 1
EndIf
If (f > 700) Then
d1 = d1 - d1
f1 = f1 - f1
endif
If (x > 290 And y > 290 And y < 291 And x < 340 And dy > 0) Then
dy = - 1
EndIf
If (x > 330 And y > 240 And y < 241 And x < 380 And dy > 0) Then
dy = - 1
EndIf
If (x > 250 And y > 170 And y < 171 And x < 280 And dy > 0) Then
dy = - 1
EndIf
If (x > 250 And y > 100 And y < 101 And x < 280 And dy > 0) Then
dy = - 1
EndIf
If (x > 360 And y > 90 And y < 91 And x < 380 And dy > 0) Then
dy = - 1
EndIf
If (key = "Right") Then
dx = .3
EndIf
If (key = "Left") Then
dx = - .3
EndIf
If (key = "Up") Then
dx = 0
EndIf
If (y > - 5) Then
Goto start2
EndIf
GraphicsWindow.ShowMessage("You win!!", "ball Bounce")