none
An Automatic Baseballs Launcher

    General discussion

  • An Automatic Baseballs  Launcher

    program no: MKQ709

    press  S   for center,   A for right    or    D for left

    You can repeat the keys many times fast, you will have double an triple balls.

    Balls from center travel faster.


    • Edited by YLedEditor Monday, February 13, 2017 7:48 PM update version, hide the ball in the upper left corner
    Monday, February 13, 2017 4:30 PM
    Answerer

All replies

  • Hi YLed,

    nice work with beautiful background and balls.

    I tried to eliminate the ball in left upper corner ( not 100% success).

    Now the Shapes will only created if the key pressed.

    New Key added: "F" for Fault if the machine blunders.

    ' an automatic baseball ball Launcher
    ' version 1
    ' by yled
    ' Feb 13th 2017
    ' program no: 
    '
    GraphicsWindow.HEIGHT=768
    GraphicsWindow.WIDTH=1366
    GraphicsWindow.top=0
    GraphicsWindow.left=0
    
    gradient[1] = "#005588"
    gradient[2] = "steelblue"
    gradient[3] = "skyblue"
    gradient[4] = "#aaddff"
    'gradient[5] = "#aaddff"
    'gradient[6] = "#ffddaa"
    gradient[5] = "#006600"
    ' gradient[8] = "#000000"
      
    sky = LDShapes.BrushGradient(gradient,"v")
    LDShapes.BrushGradientBackground(sky)
    BASEBALL=ImageList.LoadImage("https://social.msdn.microsoft.com/Forums/getfile/1001433")
    GraphicsWindow.KeyDown = OnKeyDown  
    KeyDown = 0
      
    While 1=1
    If KeyDown = 1 Then
      ball = Shapes.AddImage(BASEBALL)
      Shapes.HideShape(ball)
      Shapes.Zoom(ball,0.8,0.8)
      Shapes.Move(ball,600, 750)
      Shapes.ShowShape(ball)
      Animation()
      KeyDown = 0
    endif
    Program.Delay(3)
    ENDWHILE
    
    Sub OnKeyDown
      key= GraphicsWindow.LastKey 
      KeyDown = 1
    EndSub
      
    Sub Animation  
      If key = "S" then
          Shapes.animate(ball, 600, -100,1000)   
      EndIf 
      If key = "A" then
           Shapes.animate(ball, 10, -100,2000)   
      EndIf 
      If key = "D" then
          Shapes.animate(ball, 1300, -100,2000)   
      EndIf 
      If key = "F" then
        x=Math.GetRandomNumber(1300)
        y=Math.GetRandomNumber(200)
        Shapes.animate(ball,x,y+500,1000)   
      EndIf 
      key=""
    endsub



    Monday, February 13, 2017 10:24 PM
  • Cool ! update , thanks !

    Monday, February 13, 2017 10:58 PM
    Answerer
  • I tried a very simple change: Move the three lines in the endless loop to before the  1=1   , and a program.delay(50) in the loop:
      GraphicsWindow.KeyDown = OnKeyDown  
      ball = Shapes.AddImage(BASEBALL)
      Shapes.Move(ball,600, 758)
    
    While 1=1
      Program.Delay(50)
    ENDWHILE
    


    Jan [ WhTurner ] The Netherlands

    Tuesday, February 14, 2017 11:36 AM
    Answerer
  • @whturner

    Thanks !

    but by this way , you cannot throw multiple balls.

    Try my version , and keep pressing A,S,D many times, you will see plenty of baseballs

    Tuesday, February 14, 2017 5:07 PM
    Answerer
  • New version : with colored baseballs

    .

    An Automatic Baseballs  Launcher

    program no: DXQ638

    press  S   for center,   A for right    or    D for left

    Tuesday, February 14, 2017 5:11 PM
    Answerer