none
Why ? RRS feed

  • Question

  • I am not able to see the errors in the program: ZTK890
    The calculations do not match the graphics parabolas.
    Sorry for my English.

    In Spanish:

    -----------

    No soy capaz de ver los errores en el programa.: ZTK890
    Los calculos no coinciden con las parabolas graficas .
    Perdon por mi ingles.

    ---------------

    GraphicsWindow.Show()
    fps=50
    pgW = 598   
    pgH = 428 
    ox=50       
    oy=350  
    angle=0
    '
    init()
    '
    For ang = 30 To 60 Step 15
      angle=ang
      Shapes.Rotate(canyon,angle)
      Shapes.SetText(texAngle,(90-angle)+"º")
      angleShot=90-angle
      alpha=angleShot*(Math.Pi/180)
      Vi=14 'm/seg
      lap=0.1
      time=0  
      xpos=Shapes.GetLeft(ball)
      ypos=Shapes.GetTop(ball)  
      gravity=9.8  
      While "True"   
        time=time+lap   
        X=Vi*Math.Cos(alpha)*time
        Y=Vi*Math.Sin(alpha)*time-(gravity*(time*time))/2    
        xpos=xpos+X   
        ypos=ypos-Y     
        Shapes.Move(ball,xpos,ypos)
        GraphicsWindow.PenColor="Red"
        GraphicsWindow.DrawEllipse(xpos+b_w/2,ypos+b_h/2,2,2)
        Program.Delay(200)
        If xpos > pgW Or ypos > oy Then
          Goto EXIT
        EndIf
      EndWhile
      EXIT:
      xMax=((Vi*Vi)/gravity)*(Math.Sin(alpha*2))  
      yMax=(Vi*Vi*Math.Sin(alpha)*Math.Sin(alpha))/(gravity*2)
      drawY=drawY+20
      text1="angle: "+angleShot+" Vi: "+Vi+" Xmax: "+0.01*(Math.Round(100*xMax))+" Ymax: "+0.01*(Math.Round(100*yMax))
      GraphicsWindow.DrawBoundText(50,drawY,300, text1)
      Shapes.Move(ball,ox-b_w/2,oy-b_h/2)
      Program.Delay(1000)
    EndFor
    '
    GraphicsWindow.FontSize=40
    GraphicsWindow.DrawBoundText(100,100,200,"why?")
    
    Sub init
      GraphicsWindow.Width = pgW
      GraphicsWindow.Height = pgH
      GraphicsWindow.Top=40
      GraphicsWindow.Left=40
      GraphicsWindow.CanResize="False"
      GraphicsWindow.Title="ballistic shot"
      '
      GraphicsWindow.DrawLine(0,oy,pgW,oy)
      GraphicsWindow.DrawLine(ox,0,ox,pgH)  
      '
      'Tube  canyon
      GraphicsWindow.BrushColor="Black"
      GraphicsWindow.PenColor="Black"
      c_w=8
      c_h=15  
      c_Radio=c_h/2
      c_X=ox
      c_Y=oy 
      canyon=Shapes.AddRectangle(c_w,c_h) 
      Shapes.Move(canyon,ox-c_w/2,oy-c_h/2)
      Shapes.Rotate(canyon,angle)
      '
      'cannon ball
      GraphicsWindow.BrushColor="Red"
      GraphicsWindow.PenColor="Black"
      GraphicsWindow.PenWidth=2
      b_w=10
      b_h=10
      ball=Shapes.AddEllipse(b_w,b_h)
      Shapes.Move(ball,ox-b_w/2,oy-b_h/2)
      '
      'text angle
      GraphicsWindow.DrawText(ox-45,oy+10,"Angle")
      texAngle=Shapes.AddText(angle+"º")
      Shapes.Move(texAngle,ox-35,oy+25)
      '
      GraphicsWindow.BrushColor="Black"  
      '
    EndSub

    Thanks for your suggestions


    jalpc


    • Edited by jalpc Monday, December 8, 2014 4:05 PM
    Sunday, December 7, 2014 8:43 PM

Answers

  • Hi jalpc,

    Maybe try similar like:

    gh = GraphicsWindow.Height
    gw = GraphicsWindow.Width
    xpos = 0
    ypos = gh
    lap= 0.2
    vi = 40
    alpha = Math.GetRadians(60)  ' etc
    gravity = 9.81

    While xpos <= gw And ypos <= gh
      time=time+lap
      X=Vi*time * Math.Cos(alpha)  '' v in x direction is CONSTANT, so x grows linear over time

    '' v in y direction would be TOO, BUT minus gravity, so place for y is minus the way of free fall over time

      Y=Vi*time * Math.Sin(alpha) - gravity/2 * time*time
      xpos = X
      ypos = gh - Y
      GraphicsWindow.DrawEllipse(xpos-1,ypos-1,2,2)
      Program.Delay(100)
    EndWhile

    Edit: uups, almost forgot 'alpha'

    • Edited by Pappa LapubEditor Sunday, December 7, 2014 10:32 PM
    • Marked as answer by jalpc Monday, December 8, 2014 3:44 PM
    Sunday, December 7, 2014 10:11 PM
    Answerer

All replies

  • Hi jalpc,

    Maybe try similar like:

    gh = GraphicsWindow.Height
    gw = GraphicsWindow.Width
    xpos = 0
    ypos = gh
    lap= 0.2
    vi = 40
    alpha = Math.GetRadians(60)  ' etc
    gravity = 9.81

    While xpos <= gw And ypos <= gh
      time=time+lap
      X=Vi*time * Math.Cos(alpha)  '' v in x direction is CONSTANT, so x grows linear over time

    '' v in y direction would be TOO, BUT minus gravity, so place for y is minus the way of free fall over time

      Y=Vi*time * Math.Sin(alpha) - gravity/2 * time*time
      xpos = X
      ypos = gh - Y
      GraphicsWindow.DrawEllipse(xpos-1,ypos-1,2,2)
      Program.Delay(100)
    EndWhile

    Edit: uups, almost forgot 'alpha'

    • Edited by Pappa LapubEditor Sunday, December 7, 2014 10:32 PM
    • Marked as answer by jalpc Monday, December 8, 2014 3:44 PM
    Sunday, December 7, 2014 10:11 PM
    Answerer
  • Hi Pappa Lapub,

    Thank you for your example.
    I rewrote the program .The formulas were fine but something I was wrong. Rewrite it easier to find error.

    From this example program will try a simple interactive shooting   :-)

    In Spanish:

    --------------

    Hola Pappa Lapub:
    Gracias por su ejemplo.
    He reescrito el programa .Las formulas estaban bien pero en algo me equivocaba . Mas facil reescribirlo que buscar error.

    A partir de este ejemplo intentare un programa sencillo de tiro interactivo   :-)
    Saludos.

    --------------

    program : CFZ944

    init()
    '================  SHOT'S  =====================
    GraphicsWindow.PenColor="Red"
    For angle = 30 To 60 Step 15  
      updateCanyon()
      alpha = Math.GetRadians(angle)
      xpos = ox
      ypos = oy
      lap= 0.1
      vi = 40
      gravity = 9.81
      time=0
      factX=3   'expansion factor X
      factY=3   'expansion factor Y
      While xpos <= pgW And ypos <= oy
        time=time+lap
        X=Vi*time * Math.Cos(alpha)     
        Y=Vi*time * Math.Sin(alpha) - gravity/2 * time*time
        xpos = ox+(X*factX)
        ypos = oy-(Y*factY)
        '
        Shapes.Move(ball,xpos-b_w/2,ypos-b_h/2)
        GraphicsWindow.DrawEllipse(xpos-1,ypos-1,2,2)
        Program.Delay(50)
      EndWhile
      drawDat()
      Program.Delay(1000)
    Endfor
    '
    GraphicsWindow.FontSize=40
    GraphicsWindow.DrawBoundText(100,100,200,"OK !")
    '============================================
    '
    'Sub's
    '--------
    Sub init
      pgW = 598   
      pgH = 428 
      ox=50       
      oy=350 
      drawY=0
      GraphicsWindow.Width = pgW
      GraphicsWindow.Height = pgH
      GraphicsWindow.Top=40
      GraphicsWindow.Left=40
      GraphicsWindow.CanResize="False"
      GraphicsWindow.Title="ballistic shot"
      GraphicsWindow.DrawLine(0,oy,pgW,oy)
      GraphicsWindow.DrawLine(ox,0,ox,pgH)  
      '
      'Tube  canyon
      GraphicsWindow.BrushColor="Black"
      GraphicsWindow.PenColor="Black"
      c_w=15
      c_h=8  
      c_Radio=c_h/2
      c_X=ox
      c_Y=oy 
      canyon=Shapes.AddRectangle(c_w,c_h) 
      Shapes.Move(canyon,ox-c_w/2,oy-c_h/2)
      '
      'cannon ball
      GraphicsWindow.BrushColor="Red"
      GraphicsWindow.PenColor="Black"
      GraphicsWindow.PenWidth=2
      b_w=10
      b_h=10
      ball=Shapes.AddEllipse(b_w,b_h)
      Shapes.Move(ball,ox-b_w/2,oy-b_h/2)
      '
      'text angle
      GraphicsWindow.DrawText(ox-45,oy+10,"Angle")
      texAngle=Shapes.AddText("0º")
      Shapes.Move(texAngle,ox-35,oy+25)
      '
      GraphicsWindow.BrushColor="Black"    
    EndSub
    '
    Sub updateCanyon
      angleCanyon=-angle
      Shapes.Rotate(canyon,angleCanyon)
      Shapes.SetText(texAngle,(angle)+"º")
    EndSub
    '
    Sub drawDat
      xMax=((Vi*Vi)/gravity)*(Math.Sin(alpha*2))  
      yMax=(Vi*Vi*Math.Sin(alpha)*Math.Sin(alpha))/(gravity*2)
      drawY=drawY+20
      text1="angle: "+angle+" Vi: "+Vi+" Xmax: "+0.01*(Math.Round(100*xMax))+" Ymax: "+0.01*(Math.Round(100*yMax))
      GraphicsWindow.DrawBoundText(50,drawY,300, text1)
      Shapes.Move(ball,ox-b_w/2,oy-b_h/2)
    EndSub
    Greetings.


    jalpc

    Monday, December 8, 2014 3:57 PM
  • Fine to hear and see.

    Already used it to guide Evel Knievel over the Grand Canyon (ID: TJK684 in DT mode).

    Saturday, December 13, 2014 3:55 PM
    Answerer
  • Bravo! ....... For Evel Knievel and Pappa Lapub. :-)

    I am experiencing variations of this program, I have problems with GraphicsWindow.FontSize in silverlight.
    Program:   HPJ335

    Use arrows left / right to switch shooting angle.
    Use arrows up / down to change initial velocity

    Fire with Space
    Vd. Has 3 attempts and 60 seg. to refine marksmanship shooting
    Aid brand xMax and yMax disappears from Level 3

    Try angle = 0 !!!

    This type of program, simple aesthetic, I find attractive.
    Note: suggestions are welcome.

    In Spanish:

    -----------

    Bravo! ....... para Evel Knievel y para Pappa Lapub. :-)

    Estoy experimentando variaciones de este programa , tengo problemas con  GraphicsWindow.FontSize  en silverlight.

    Programa:  HPJ335

    Utilizar flechas left / right para cambiar angulo tiro .
    Utilizar Flechas up / down para cambiar velocidad inicial

    Fuego con espaciador
    Vd. tiene 3 intentos y 60 seg. por tiro para afinar punteria 
    La ayuda de marcas de xMax e yMax desaparece a partir de nivel 3

    ¡¡¡¡ Pruebe el angulo = 0 !!!!!

    Este tipo de programas, de estetica sencilla , me resultan atractivos . 

    Nota: Se admiten sugerencias . 

    -----------


    jalpc






    • Edited by jalpc Saturday, December 13, 2014 9:05 PM
    Saturday, December 13, 2014 8:22 PM
  • Whauh, thats really COOL man!!

    In silverlight (and on Import) ALL GraphicsWindow.FontSize are commented out for HPJ335. If you did'nt do that ?, prob. silverlight does'nt accept it.

    But if it's an issue i suppose that Nonki sure has written an article (Small Basic FontSize  search) about that.

    eg: 21694 - Font and Pen Width Change Earlier in Remote

    Saturday, December 13, 2014 9:21 PM
    Answerer
  • Thank you ...:-)

    It puden many variations on the same basis.

    No, not important GraphicsWindow.FontSize.

    question: which is how in DT mode? . (Vd it says next to TJK684)

    "Already used it to guide Evel Knievel over the Grand Canyon (ID: TJK684 in DT mode)."

    In Spanish:

    ----------

    Gracias... :-)

    Se puden hacer muchas variaciones con la misma base.

    No, No es importante GraphicsWindow.FontSize .

    pregunta: que es  ¿ in DT mode ? . (Vd lo comenta al lado de TJK684)

    "Already used it to guide Evel Knievel over the Grand Canyon (ID: TJK684 in DT mode)."


    jalpc


    • Edited by jalpc Saturday, December 13, 2014 9:39 PM
    Saturday, December 13, 2014 9:37 PM
  • Oh, i meant 'local mode', by Import (~ desktop mode) because some funcs won't work in silverlight.
    Saturday, December 13, 2014 11:10 PM
    Answerer
  • Oh, i meant 'local mode', by Import (~ desktop mode) because some funcs won't work in silverlight.

    Hi Pappa Lapub:

    ok. I understand.

    IMPORTANT NOTICE: The engine of the motorcycle Evel Knievel has trouble combustion and power ...

    import and see VMC450 :-) (only local mode)


    jalpc

    Sunday, December 14, 2014 4:04 PM
  • hi Pappa Lapub,

    CHALLENGE: Evel Knievel could turn his bike during the jump?

    Greetings:-)

    in Spanish

    ------------

    hola,

    RETO : Se atreveria a reprogramar para que , Evel Knievel, girara su moto durante el salto ?

    Saludos :-)


    jalpc

    Sunday, December 14, 2014 6:51 PM
  • HaHa, That one was good! What a shame and really bad ;-). Walls motiveless against him, but his fxrt bubbles are sweet.

    CHALLENGE: Evel Knievel could turn his bike during the jump?

    ... salto mortale ... Anyone else? You're good in game coding! Like to and would prefer around xMas holidays next week. Wanna deliver some ShellIntegrations in modular principle first.

    Se puden hacer muchas variaciones con la misma base.

    Also thought about a wintery version with separate whiteboard to 'write/shoot' excalamation marks!¡:|¦ and a certain BGTrack from Apostrophe, HaHa.

    Sunday, December 14, 2014 7:54 PM
    Answerer
  • Hi Pappa,

    Happy Holidays Christmas .

    -------

    ---> " HaHa, That one was good! What a shame and really bad ;-). Walls motiveless against him, "<---

    ------

    Sorry, sorry .... I do not resisted the temptation. I will not do more. HaHa . :-)

    -------

    ----> " CHALLENGE: Evel Knievel could turn his bike during the jump?

    ... salto mortale ... Anyone else? You're good in game coding! Like to and would prefer around xMas holidays next week. Wanna deliver some ShellIntegrations in modular principle first. " <----

    --------

    Ok. I'll try.

    ---------

    ----> "Also thought about a wintery version with separate whiteboard to 'write/shoot' excalamation marks!¡:|¦ and a certain BGTrack from Apostrophe, HaHa. "" <----

    ---------

    My English is very poor and Google Translate tells me things that I can not fully understand.

    But I get a rough idea ... HaHa  :-)

    Excuse me if I say "strange things" in my bad English. No doubt that will always be good and pleasant things.

    Happy Holidays Christmas .

    jalpc


    jalpc

    Monday, December 15, 2014 4:37 PM
  • Hi Pappa,

    Challenge loop Evel Knievel ........... :-) .

    ¡¡¡¡ Works on PC and SilverLight !!!.

    SilverLight problem in imageList.GetWidthOfImage (eKnievel) and  ImageList.GetHeightOfImage (eKnievel) returns 0 in both.

    Program: XXS713

    'challenge E.K. V 1.0
    'jalpc January 2015
    'image canstock6287653.jpg property of Pappa Lapub
    '
    'Silverlight ?
    color = GraphicsWindow.GetPixel(0, 0)
    If Text.GetLength(color) > 7 Then
      silverlight = "True"
    Else
      silverlight = "False"
    EndIf
    '
    GraphicsWindow.Show() 
    GraphicsWindow.Hide()
    data_()
    form_()
    graphics_()
    moveRamp_()
    GraphicsWindow.Show()
    '
    While "True"
      Program.Delay(1000)
      jump_()
      init_()
    EndWhile
    '
    Sub form_
      GraphicsWindow.Width = pgW-5
      GraphicsWindow.Height = pgH-5
      GraphicsWindow.Top=40
      GraphicsWindow.Left=40
      GraphicsWindow.CanResize="False"
      GraphicsWindow.Title="CHALLENGE E.K. V1.0"
    EndSub
    '
    Sub graphics_
      ' rampa para saltar
      GraphicsWindow.BrushColor="Gray"
      GraphicsWindow.PenColor="Gray"
      r_w=longRamp
      r_h=4
      r_x =ox-r_w
      r_y =oy-r_h/2  
      r_rx=r_w/2        'separacion del centro de rotacion en x
      r_ry=0            'separacion del centro de rotacion en y
      ramp = Shapes.AddRectangle(r_w,r_h)
      Shapes.Move(ramp,r_x,r_y)  
      '
      'suelo (ground)
      GraphicsWindow.FillRectangle(0,pgH-60,pgW,4)      'suelo base
      GraphicsWindow.FillRectangle(450,oy+20,148,53)    'suelo llegada
      GraphicsWindow.FillTriangle(38,368,94,368,94,312) 'apoyo rampa
      '
      'bala (centro rotacion externo de la rampa) y traza de parabola
      eKnievel = "http://l.thumbs.canstockphoto.com/canstock6287653.jpg"
      ball1 = Shapes.AddImage(eKnievel)
      b1_w = ImageList.GetWidthOfImage(eKnievel)
      b1_h = ImageList.GetHeightOfImage(eKnievel) 
      '============= ????????
      If silverlight Then
        difSilverX=70.5 ' es la mitad del ancho en local = 141 (en remoto vale 0 ??)
        difSilverY=75   ' es la mitad del alto en local  = 150 (en remoto vale 0 ??)
      Else
        difSilverX=0
        difSilverY=0
      EndIf
      '==============
      b1_x=ox-b1_w/2-difSilverX
      b1_y=oy-b1_h/2-difSilverY
      Shapes.Zoom(ball1, .2,.2)
      Shapes.HideShape(ball1)
      Shapes.Move(ball1,b1_x,b1_y)
      Shapes.ShowShape(ball1)
    EndSub
    '
    Sub moveRamp_
      angleRamp=-angle
      Shapes.Rotate(ramp,angleRamp)  
      rotateX=r_rx
      rotateY=r_ry
      rad = Math.GetRadians(angleRamp)
      difX = rotateX*Math.Cos(rad) - rotateY*Math.Sin(rad)
      difY = rotateX*Math.Sin(rad) + rotateY*Math.Cos(rad)  '
      x=r_x+ rotateX-difX
      y=r_y+rotateY-difY  '
      Shapes.Move(ramp,x,y)
    EndSub
    '
    Sub jump_
      'color para traza de bala
      GraphicsWindow.BrushColor="Gray"
      GraphicsWindow.PenColor="Gray"
      GraphicsWindow.PenWidth=1
      alpha = Math.GetRadians(angle)
      xpos = ox
      ypos = oy
      lap= 0.1
      vi = 62
      gravity = 9.81
      time=0
      lapDraw=0
      stepDraw=2
      itemPoint=0
      While xpos <= pgW And ypos <= oy
        lapDraw=lapDraw+1
        time=time+lap
        X=Vi*time * Math.Cos(alpha)     
        Y=Vi*time * Math.Sin(alpha) - gravity/2 * time*time
        xpos = ox+X
        ypos = oy-Y
        If silverlight Then
          Shapes.Move(ball1,xpos-b1_w/2-difSilverX,ypos-b1_h/2-difSilverY) 
        Else
          Shapes.Move(ball1,xpos-b1_w/2,ypos-b1_h/2) 
        EndIf       
       '
        'Rotacion moto
        If itemPoint <= 36 Then
          Shapes.Rotate(ball1,-itemPoint*10)
        Else
          Shapes.Rotate(ball1,0)
        EndIf
        '
        If Math.Remainder(lapDraw,stepDraw)=0 Then
          itemPoint=itemPoint+1
          Shapes.Move(point[itemPoint],xpos-1,ypos-1)  
          Shapes.ShowShape(point[itemPoint]) 
        EndIf
        Program.Delay(50)
      EndWhile
      For num = 1 To itemPoint
        Shapes.Zoom(point[num],3,3)
        Program.Delay(20)
        Shapes.Zoom(point[num],.3,.3)
        Program.Delay(20)
        Shapes.HideShape(point[num])
        Shapes.Zoom(point[num],1,1)
      EndFor  
    EndSub
    '
    Sub init_
      Shapes.Move(ball1,b1_x,b1_y)
    EndSub
    '
    Sub data_
      pgW = 598       
      pgH = 428       
      ox=100          'origen x coordenada inicial
      oy=300          'origen y coordenada inicial
      longRamp=100    'largo rampa = radio Giro
      angleInit=45    'angulo inicial de la bala
      angle=angleInit 'angulo variable  de la bala  
      'objetos traza trayectoria
      For itemPoint = 1 To 100
        Shapes.HideShape(point[itemPoint])
        point[itemPoint]=Shapes.AddEllipse(3,3)  
      EndFor
    EndSub

    regards.


    jalpc

    Tuesday, January 20, 2015 7:24 PM
  • Hi jalpc,

    really great done, man! Had some ideas about using an Epizycloide before the flu, but than layed it all ad acta. With param coords or similar, and when watching the salto i think you did it this way, but 'll look at he code tomorrow. Hm, there's a 'Shape.Rotate(ball' prob. with the guy on it's circumference. Browser mode looks less realistic for me. The guy travels back while in the air :-(. But offline mode's pretty nice and on repeat.

    Tuesday, January 20, 2015 11:01 PM
    Answerer
  • Hi Pappa Lapub,

    If XXS713 (on website) runs before executing the same program on pc does not behave well when turning the motorcycle.

    Try to import XXS713 your pc. After publishing the program and run in Silverligth and the new name in Silverlight works just as in the pc.

    If it runs on Silverlight before running on PC does not behave like the pc.

    If executed first and then in Silverlight pc behaves identically.

    It is a strange behavior.

    In Spanish:

    -----------

    Hi Pappa Lapub .

    Si se ejecuta XXS713 (en pagina web) antes de ejecutar el mismo programa en pc no se comporta bien al girar la motocicleta.

    Pruebe a importar XXS713 a su pc. Despues publique el programa y ejecute en SilverLigth y con el nuevo nombre: Funciona igual en Silverlight que en el pc .

    Si se ejecuta (en pagina web ) antes de ejecutar en pc no se comporta igual que en el pc.

    Si se ejecuta primero en pc y despues en Silverlight se comporta de forma identica. 

    Es un comportamiento extraño.


    jalpc

    Friday, January 30, 2015 4:20 PM