Microsoft Small Basic

Program Listing:
Embed this in your website
GraphicsWindow.PenWidth=0 'This prevents the following objects to habe black lines around them. Makes them "prettier" :P
GraphicsWindow.BrushColor="Purple" 'Sets the color for all the "Swarm" objects.
For i = 1 to 20 'Add 20 "Swarm" objects
  Swarm[i]=shapes.AddEllipse(10,10) 'This adds 20 "Swarm" objects. Wich are circles of 10x10 pixels here. This can be changed to every object you want.
  SX[i]=Math.GetRandomNumber(150)+225 'This here sets the X Position of every "Swarm" object to a random value
  SY[i]=Math.GetRandomNumber(150)+225 'This here sets the Y Position of every "Swarm" object to a random value
endfor
While "true" 'Main Loop
  For i = 1 To 20 'Do the following for all 20 "Swarm" objects:
    If SY[i]<GraphicsWindow.MouseY and SWY[i] < 15 Then 'Accelerates the "Swarm" object down, if it is higher than the Cursor.
      SWY[i]=SWY[i]+0.5 'Increases the Y Speed by 0.5. Its name is WY because Wucht means momentum in german. (this might be not the right name, but im familiar with it that way)
    elseIf SY[i] > GraphicsWindow.MouseY and SWY[i] > -15 THen 'Accelerates the "Swarm" object up, if it is lower than the Cursor.
      SWY[i]=SWY[i]-0.5 'Decreases the Y Speed by -0.5.
    endif
    If SX[i] < GraphicsWindow.MouseX and SWX[i] < 15 THen 'Accelerates the "Swarm" object to the right side, if it is on the left side of the Cursor.
      SWX[i]=SWX[i]+0.5 'Increases the X Speed by 0.5.
    elseIf SX[i] > GraphicsWindow.MouseX and SWX[i] > -15 THen 'Accelerates the "Swarm" object to the left side, if it is on the right side of the Cursor.
      SWX[i]=SWX[i]-0.5 'Decreases the X Speed by -0.5.
    endif
    SX[i]=SX[i]+SWX[i] ' "Combines" the X position of the "Swarm" object with its X speed. This isnt necessary, shapes.move(Swarm[i],SX[i]+SWX[i],SY[i]+SWY[i]), can also be used instead. But this method gives it better overview and makes it easyer to call an objects position.
    SY[i]=SY[i]+SWY[i] ' "Combines" the Y position of the "Swarm" object with its Y speed
    Shapes.Move(Swarm[i],SX[i]+5,SY[i]+5) ' Moves the "Swarm" object to its new assigned position. The +5 is there to make the object move around its center. And its +5 Because the radius of the object is 5 pixels.
  endfor
  Program.Delay(10)' Added a delay of 10 Milliseconds to limit the programs speed. Try to remove it, and see what happens ;D
endwhile 'End of main loop
Copyright (c) Microsoft Corporation. All rights reserved.