Microsoft Small Basic

Program Listing:
Embed this in your website
GraphicsWindow.CanResize = 0
GraphicsWindow.Height = (Desktop.Height/2)
GraphicsWindow.Width = (Desktop.Width - 500)
GH = GraphicsWindow.Height
GW = GraphicsWindow.Width
GraphicsWindow.PenColor = "Black"
GraphicsWindow.PenWidth = "2"
Lin = 0
LinH:
For i = 1 to (GW/10)
Lin = Lin + 10
Program.Delay(10)
Shapes.AddLine(Lin, 0, Lin, GH)
Endfor
Lint = 0
For i = 1 to (GH/10)
Lint = Lint + 10
Program.Delay(10)
Shapes.AddLine(0, Lint, GW, Lint)
Endfor
Program.Delay(10)
H = 0
r = 173
g = 255
b = 47
He = GraphicsWindow.GetColorFromRGB(r, g, b)
GraphicsWindow.Title = "Batting Practice"
GraphicsWindow.PenWidth = 1
GraphicsWindow.PenColor = "Black"
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.BackgroundColor = "Green"
Foot2 = Shapes.AddRectangle(30, 15)
GraphicsWindow.PenColor = "White"
GraphicsWindow.BrushColor = "White"
Shapes.Move(Foot2, 130, (GH - 50))
LegF = Shapes.AddRectangle(21, 50)
Shapes.Move(LegF, 130, (GH - 100))
LegF2 = Shapes.AddRectangle(45, 21)
Shapes.Move(LegF2, 100, (GH - 100))
Mid = Shapes.AddRectangle(42, 35)
Shapes.Move(Mid, 85, (GH - 114))
GraphicsWindow.PenWidth = 21
Shapes.AddLine(35, (GH - 45), 92, (GH - 89))
GraphicsWindow.PenColor = "Black"
GraphicsWindow.BrushColor = "Black"
Foot1 = Shapes.AddRectangle(30, 15)
Shapes.Move(Foot1, 30, (GH - 50))
GraphicsWindow.PenColor = "DarkRed"
GraphicsWindow.BrushColor = "DarkRed"
Ground = Shapes.AddRectangle(GW, 50)
Shapes.Move(Ground, 0, (GH - 40))
GraphicsWindow.PenColor = "Yellow"
GraphicsWindow.BrushColor = "Blue"
Body = Shapes.AddRectangle(42, 65)
Shapes.Move(Body, 85, (GH - 175))
Arm1 = Shapes.AddRectangle(20, 16)
Shapes.Move(Arm1, 127, (GH - 149))
GraphicsWindow.PenWidth = "1"
GraphicsWindow.PenColor = "DarkRed"
GraphicsWindow.BrushColor = "Tan"
Hand = Shapes.AddRectangle(16, 16)
Shapes.Move(Hand, 148, (GH - 149))
GraphicsWindow.PenWidth = "2"
GraphicsWindow.PenColor = "White"
Shapes.addline(147, (GH - 149), 147, (GH - 133))
GraphicsWindow.PenColor = "Darkred"
GraphicsWindow.PenWidth = "1"
Head = Shapes.AddEllipse(50, 50)
Shapes.Move(Head, 80, 230)
GraphicsWindow.BrushColor = "Gray"
GraphicsWindow.PenColor = "Gray"
Base = Shapes.AddRectangle(100, 50)
Shapes.Move(Base, (GW - 110), (GH - 110))
Leg1 = Shapes.AddRectangle(10, 20)
Shapes.Move(Leg1, (GW - 110), (GH - 60))
Leg2 = Shapes.AddRectangle(10, 20)
Shapes.Move(Leg2, (GW - 20), (GH - 60))
GraphicsWindow.BrushColor = "Gray"
GraphicsWindow.PenColor = "Gray"
GraphicsWindow.PenWidth = 4
Shapes.AddLine((GW - 85), (GH - 135), (GW - 85), (GH - 165))
Shapes.AddLine((GW - 25), (GH - 110), (GW - 25), (GH - 165))
GraphicsWindow.PenWidth = "1"
GraphicsWindow.PenColor = "Red"
GraphicsWindow.BrushColor = He
Ball1 = Shapes.AddEllipse(20, 20)
Shapes.Move(Ball1, (GW - 45), 320)
Ball1 = Shapes.AddEllipse(20, 20)
Shapes.Move(Ball1, (GW - 65), 320)
Ball1 = Shapes.AddEllipse(20, 20)
Shapes.Move(Ball1, (GW - 85), 320)
Ball1 = Shapes.AddEllipse(20, 20)
Shapes.Move(Ball1, (GW - 45), 300)
Ball1 = Shapes.AddEllipse(20, 20)
Shapes.Move(Ball1, (GW - 65), 300)
Ball1 = Shapes.AddEllipse(20, 20)
Shapes.Move(Ball1, (GW - 85), 300)
Ball1 = Shapes.AddEllipse(20, 20)
Shapes.Move(Ball1, (GW - 45), 280)
Ball1 = Shapes.AddEllipse(20, 20)
Shapes.Move(Ball1, (GW - 65), 280)
Ball1 = Shapes.AddEllipse(20, 20)
Shapes.Move(Ball1, (GW - 85), 280)
Barrel = Shapes.AddRectangle(75, 25)
Shapes.Move(Barrel, (GW - 140), (GH - 135))
GraphicsWindow.PenColor = "Black"
GraphicsWindow.BrushColor = "Black"
Power = Shapes.AddEllipse(50, 50)
Shapes.Move(Power, (GW - 95), (GH - 135))
GraphicsWindow.BrushColor = "Red"
Stp = Controls.AddButton("Quit", 10, (GH - 33))
GraphicsWindow.BrushColor = "Blue"
Mut = Controls.AddButton("Mute", 50, (GH - 33))
GraphicsWindow.BrushColor = "Blue"
Snd = Controls.AddButton("Music", 95, (GH - 33))
GraphicsWindow.BrushColor = "Green"
Hlp = Controls.AddButton("Help", 144, (GH - 33))
GraphicsWindow.BrushColor = "Red"
Ins = Controls.AddMultiLineTextBox((GW - (GW/2 + 150)), (GH - 33))
    Controls.SetSize(Ins, 300, 25)
  BC = "Brown"
  Pen = "Black"
    GraphicsWindow.PenColor = "DarkRed"
    GraphicsWindow.BrushColor = "Red"
    ear1 = Shapes.AddEllipse(15, 15)
    Shapes.Move(ear1, 90, 247)
    GraphicsWindow.BrushColor = "Tan"
    ear2 = Shapes.AddEllipse(6, 6)
    shapes.move(ear2, 95, 252)
    GraphicsWindow.BrushColor = "Red"
    Shapes.AddTriangle(79, 250, 95, 248, 95, 230)
    Shapes.AddTriangle(131, 250, 115, 248, 115, 230)
    cap = Shapes.AddRectangle(20, 18)
    Shapes.Move(cap, 95, 230)
      vis = Shapes.AddEllipse(60, 5)
      Shapes.Move(vis, 78, 245)
    GraphicsWindow.BrushColor = "Green"
    Controls.SetTextBoxText(Ins, "Wood Bat! (" + H + " Pts)")
    Sound.PlayChimeAndWait()
    UT = 1
    F = 0
    Spd = 500
    UT1 = 0
    UT2 = 0
    UT3 = 0
    UT4 = 0
    UT5 = 0
    UT6 = 0
    UT7 = 0
    Begin:
    Rd = Math.GetRandomNumber(5)
Controls.ButtonClicked = Button
Sub Button
  Bilbo =  Controls.LastClickedButton
  If (Bilbo = Stp) Then
    Sound.PlayClick()
    GraphicsWindow.ShowMessage("Closing...", "")
    Program.Delay(1500)
    Program.End()
  ElseIf(Bilbo = Std) Then
    Controls.Remove(Std)
      ElseIf (Bilbo = Hlp) Then
        Sound.PlayClick()
        Std = Controls.AddButton("Set", 185, (GH - 33))
    GraphicsWindow.ShowMessage("In 'Batting Practice', the player presses the space bar to swing the bat. For every Home Run, one point is gained. For every foul, one point is lost. Fouls are given if the ball is hit incorrectly, or if the player swings at a Ball (when the ball is out of the strike zone). For every five points gained, the player's bat is upgraded. For every three strikes in a row, the player loses all of their points. There are random 'Speed Rounds' on every fourth bat upgrade. If the player reaches 40 points, the game ends.", "")
  GraphicsWindow.ShowMessage("Click on the Set button.", "")
Elseif (Bilbo = Mut) Then
  Sound.PlayClick()
  Std = Controls.AddButton("Set", 185, (GH - 33))
    Sound.Stop("C:\Users\Cody\Downloads\Take Me Out To The Ballgame.mp3")
    GraphicsWindow.ShowMessage("Click on the Set button.", "")
  Elseif (Bilbo = Snd) Then
  Sound.PlayClick()
   Sound.Stop("C:\Users\Cody\Downloads\Take Me Out To The Ballgame.mp3")
    Std = Controls.AddButton("Set", 185, (GH - 33))
    GraphicsWindow.ShowMessage("Click on the Set Button", "LOADING MUSIC...")
    Sound.Play("C:\Users\Cody\Downloads\Take Me Out To The Ballgame.mp3")
  EndIf


Endsub
If(H = 5) and ((UT1 = 0) Or (UT1 = 2)) Then
  BC = "Black"
  Pen = "LightGray"
  UT1 = 1
      Spd = 500
 GraphicsWindow.BrushColor = "Green"
 Controls.SetTextBoxText(Ins, "Upgrade to Aluminum bat! (" + H + " Pts)")
 Sound.PlayChimeAndWait()
Elseif (H = 10) and (UT2 = 0) Then
  BC = "Red"
  Pen = "Black"
  UT2 = 1
      Spd = 500
 GraphicsWindow.BrushColor = "Green"
 Controls.SetTextBoxText(Ins, "Upgrade to Red bat! (" + H + " Pts)")
 Sound.PlayChimeAndWait()
Elseif (H = 15) and (UT3 = 0)Then
  BC = "Green"
  Pen = "Orange"
  UT3 = 1
      Spd = 500
 GraphicsWindow.BrushColor = "Green"
 Controls.SetTextBoxText(Ins, "Upgrade to Green bat! (" + H + " Pts)")
 Sound.PlayChimeAndWait()
Elseif (H = 20) and (UT4 = 0) Then
BC = "Purple"
Pen = "Yellow"
UT4 = 1
    Spd = 500
 GraphicsWindow.BrushColor = "Green"
 Controls.SetTextBoxText(Ins, "Upgrade to Magic Bat! (" + H + " Pts)")
 Sound.PlayChimeAndWait()
 If (Rd < 5) Then
  Spd = 250
   GraphicsWindow.BrushColor = "Orange"
   Controls.SetTextBoxText(Ins, "Speed Round! (" + H + " Pts)")
   Sound.PlayChimeAndWait()
Endif
Elseif (H = 25) and (UT5 = 0) Then
  BC = "Orange"
  Pen = "DarkRed"
  UT5 = 1
      Spd = 500
 GraphicsWindow.BrushColor = "Green"
 Controls.SetTextBoxText(Ins, "Upgrade to Fire Bat! (" + H + " Pts)")
 Sound.PlayChimeAndWait()
Elseif (H = 30) and (UT6 = 0) Then
  BC = "LightGrey"
  Pen = "White"
  UT6 = 1
      Spd = 500
   GraphicsWindow.BrushColor = "Green"
   Controls.SetTextBoxText(Ins, "Upgrade to Silver Bat! (" + H + " Pts)")
   Sound.PlayChimeAndWait()
Elseif (H = 35) and (UT7 = 0) Then
  BC = "Yellow"
  Pen = "Orange"
  UT7 = 1
  Spd = 500
 GraphicsWindow.BrushColor = "Green"
 Controls.SetTextBoxText(Ins, "Upgrade to Gold Bat! (" + H + " Pts)")
 Sound.PlayChimeAndWait()
    If (Rd < 3) Then
    Spd = 250
    GraphicsWindow.BrushColor = "Orange"
   Controls.SetTextBoxText(Ins,"Speed Round!")
    Sound.PlayChimeAndWait()
    Endif
  ElseIf ((H = 0) or (H = 4)) and (UT1 = 1) Then
  BC = "Brown"
  Pen = "Black"
  Spd = 500
  UT1 = 0
 GraphicsWindow.BrushColor = "Red"
 Controls.SetTextBoxText(Ins, "Downgrade to Wood Bat! (" + H + " Pts)")
 Sound.PlayChimeAndWait()
Elseif(H = 9) and (UT2 = 1) Then
  BC = "Black"
  Pen = "LightGray"
  UT2 = 0
      Spd = 500
 GraphicsWindow.BrushColor = "Red"
 Controls.SetTextBoxText(Ins, "Downgrade to Aluminum bat! (" + H + " Pts)")
  Sound.PlayChimeAndWait()
Elseif (H = 14) and (UT3 = 1) Then
  BC = "Red"
  Pen = "Black"
  UT3 = 0
      Spd = 500
 GraphicsWindow.BrushColor = "Red"
 Controls.SetTextBoxText(Ins, "Downgrade to Red bat! (" + H + " Pts)")
  Sound.PlayChimeAndWait()
Elseif (H = 19) and (UT4 = 1)Then
  BC = "Green"
  Pen = "Orange"
  UT4 = 0
      Spd = 500
 GraphicsWindow.BrushColor = "Red"
 Controls.SetTextBoxText(Ins, "Downgrade to Green bat! (" + H + " Pts)")
  Sound.PlayChimeAndWait()
Elseif (H = 24) and (UT5 = 1) Then
BC = "Purple"
Pen = "Yellow"
UT5 = 0
    Spd = 500
 GraphicsWindow.BrushColor = "Red"
 Controls.SetTextBoxText(Ins, "Downgrade to Magic Bat! (" + H + " Pts)")
  Sound.PlayChimeAndWait()
Elseif (H = 29) and (UT6 = 1) Then
  BC = "Orange"
  Pen = "DarkRed"
  UT6 = 0
      Spd = 500
 GraphicsWindow.BrushColor = "Red"
 Controls.SetTextBoxText(Ins, "Downgrade to Fire Bat! (" + H + " Pts)")
  Sound.PlayChimeAndWait()
Elseif (H = 34) and (UT7 = 1) Then
  BC = "LightGray"
  Pen = "White"
  UT7 = 0
      Spd = 500
 GraphicsWindow.BrushColor = "Red"
 Controls.SetTextBoxText(Ins, "Downgrade to Silver Bat! (" + H + " Pts)")
  Sound.PlayChimeAndWait()
ElseIf (H > 39) Then
  Shapes.Remove(Bat)
  Shapes.Remove(Bat2)
 GraphicsWindow.BrushColor = "Red"
 Controls.SetTextBoxText(Ins, "Hurray, you finished the game!")
  Sound.PlayChimeAndWait()
  Program.Delay(1500)
  Program.end()
Endif
GraphicsWindow.PenColor = Pen
GraphicsWindow.BrushColor = BC
Bat = Shapes.AddRectangle(14, 65)
Shapes.HideShape(Bat)
Shapes.Move(Bat, 149, (GH - 213))
Shapes.ShowShape(Bat)
Bat2 = Shapes.AddRectangle(14, 8)
Shapes.HideShape(Bat2)
Shapes.Move(Bat2, 149, (GH - 135))
Shapes.ShowShape(Bat2)
GraphicsWindow.KeyDown = KeyDown
GraphicsWindow.PenColor = "Red"
GraphicsWindow.BrushColor = He
Ball = Shapes.AddEllipse(20, 20)
Shapes.HideShape(Ball)
Shapes.Move(Ball, (GW - 90), 319)
Shapes.ShowShape(Ball)
GraphicsWindow.PenColor = "Gray"
GraphicsWindow.BrushColor = "LightGray"
Barrel = Shapes.AddRectangle(80, 25)
Shapes.SetOpacity(Barrel, 75)
Shapes.Move(Barrel, (GW - 140), (GH - 135))
GraphicsWindow.PenColor = "LightGray"
GraphicsWindow.BrushColor = "Black"
Power = Shapes.AddEllipse(50, 50)
Shapes.Move(Power, (GW - 95), (GH - 135))
Shapes.SetOpacity(Power, 75)
D = Spd
Program.Delay(1000)
Chance = Math.GetRandomNumber(5)
If (Chance = 2) Then
  Y = 100
ElseIf (Chance = 1) Then
  Y = (GH - 50)
Else
Y = (GH - 185)
Endif
If (Chance < 3) Then
  X = -100
Else
  X = 165
EndIf
Shapes.Animate(Ball, (GW - 155), 319, 200)
Program.Delay(200)
Shapes.Animate(Ball, X, Y, D)
T = 0
Timer.Interval = Spd/4
Timer.Tick = Tick
Sub Tick
  T = T + 1
EndSub
K = 0
Sub Keydown
  K = 1
  Shapes.Remove(Bat2)
  Shapes.Remove(Bat)
  GraphicsWindow.BrushColor = BC
  GraphicsWindow.PenColor = Pen
  Bat = Shapes.AddRectangle(66, 14)
  Shapes.Move(Bat, 163, (GH - 148))
  If (T > 4) Then
    Shapes.Remove(Ball)
    F = 0
     GraphicsWindow.BrushColor = "Orange"
     Controls.SetTextBoxText(Ins, "Too Late! (" + H + " Pts)")
     Goto Again
   Endif

  If (Chance > 2) Then
  Shapes.Remove(Ball)
  GraphicsWindow.BrushColor = "Red"
  GraphicsWindow.PenColor = He
  Ball = Shapes.AddEllipse(20, 20)
  If (T = 1) or (T = 2)Then
    Shapes.Remove(Ball)
    F = 0
     GraphicsWindow.BrushColor = "Orange"
    Controls.SetTextBoxText(Ins, "Too soon! (" + H + " Pts)")
    Goto Again
  ElseIf  (T = 3) Then
    Sound.PlayClick()
    Shapes.Move(Ball, X, Y)
    Shapes.Animate(Ball, GW, (GH - 50), Spd + 300)
    H = H - 1
    F = F + 1
    If (F = 3) Then
F = 0
 GraphicsWindow.BrushColor = "Red"
 Controls.SetTextBoxText(Ins, "STRIKE 3! Lose all points! (0 Pts)")
H = 0
Goto Again
Endif
    If (H < 0) Then
H = 0
Endif
 GraphicsWindow.BrushColor = "Red"
    Controls.SetTextBoxText(Ins, "Foul! STRIKE " + F + "! -1Pt (" + H + " Pts)")
    Goto Again
  ElseIf (T = 4) Then
    Sound.PlayClick()
    Shapes.Move(Ball, X, Y)
    Shapes.Animate(Ball, (GW + 100), 0, Spd)
    H = H + 1
    F = 0
    If (H < 0) Then
H = 0
Endif
     GraphicsWindow.BrushColor = "Green"
     Controls.SetTextBoxText(Ins, "Home Run! +1Pt (" + H + " Pts)")
    Goto Again
    EndIf
  Elseif (Chance < 3) and (T < 5) and (T > 2) Then
    Program.Delay(300)
    H = H - 1
    F = F + 1
    If (F = 3) Then
      F = 0
      H = 0
 GraphicsWindow.BrushColor = "Red"
    Controls.SetTextBoxText(Ins, "STRIKE 3! Lose all points! (0 Pts)")
Goto Again
Endif
    If (H < 0) Then
H = 0
Endif
     GraphicsWindow.BrushColor = "Red"
     Controls.SetTextBoxText(Ins, "Foul! STRIKE " + F + "! -1Pt (" + H + " Pts)")
    Goto Again
  Endif
EndSub

Sound.PlayClick()
Program.Delay(Spd)
Sound.PlayClick()
Shapes.Move(Ball, X, Y)
Shapes.Animate(Ball, GW, (GH - 50), 800)
Program.Delay(D*4)
Shapes.Remove(Ball)
Shapes.Remove(Bat)
Goto Begin
Again:
Shapes.Remove(Ball)
Shapes.Remove(Bat)
Program.Delay(D*4)
Goto Begin
Copyright (c) Microsoft Corporation. All rights reserved.