none
mahreen miangul ApRil 2017

Answers

  • Read the comments and see what happens now

    GraphicsWindow.DrawLine(0,50, GraphicsWindow.Width,50)
    GraphicsWindow.DrawEllipse(50,50, -30,-30)     ' 2 neg. values, mirrors about its anchor point
    GraphicsWindow.FillEllipse(100,50, -30,-30)    ' 2 neg values, mirrors about its anchor point
    ell = Shapes.AddEllipse(0,0)                  ' zero size = currently invisible
    Shapes.Move(ell, 150,50)
    
    GraphicsWindow.DrawLine(0,100, GraphicsWindow.Width,100)
    'GraphicsWindow.PenWidth = 5
    GraphicsWindow.DrawRectangle(50,110, 0,0)      ' 2 zero values -> single 'point' in PenWidth
    GraphicsWindow.FillRectangle(50,120, 0,0)     ' 1 zero value = invisible, no line, no point
    rect = Shapes.AddRectangle(0,0)               ' zero size = currently invisible
    Shapes.Move(rect, 150,100)
    
    ' pump up the Shapes
    While "True"
      For wh = 0 To 100
        Controls.SetSize(ell, wh,wh)
        Controls.SetSize(rect, wh,wh)
        Program.Delay(20)
      EndFor
      Program.Delay(1000)
      For wh = 100 To 0 Step -1
        Controls.SetSize(ell, wh,wh)
        Controls.SetSize(rect, wh,wh)
        Program.Delay(20)
      EndFor
    EndWhile


    Friday, March 31, 2017 9:14 AM
    Answerer

All replies

  • hello everybody Dumty ID BLD217

    here is a program with similar codes for a rectangle and a ellipse the ellipse is drawing but the rectangle is not comming this not my program it is from small basic forum which i down loaded GraphicsWindow.DrawLine(0,50,GraphicsWindow.Width,50)
    GraphicsWindow.DrawEllipse(50,50,-30,-30)     ' neg. values
    GraphicsWindow.FillEllipse(100,50,-30,-30)    ' neg values
    Ell = Shapes.AddEllipse(0,0)                  ' zero
    Shapes.Move(Ell,150,50)

    GraphicsWindow.DrawLine(0,100,GraphicsWindow.Width,100)
    GraphicsWindow.DrawRectangle(50,100,0,0)      ' zero values
    GraphicsWindow.FillRectangle(100,100,0,0)     ' zero values
    Rect = Shapes.AddRectangle(0,0)               ' zero
    Shapes.Move(Rect,150,100)
                                                with thanks         mahreen miangul


    Friday, March 31, 2017 6:09 AM
  • Read the comments and see what happens now

    GraphicsWindow.DrawLine(0,50, GraphicsWindow.Width,50)
    GraphicsWindow.DrawEllipse(50,50, -30,-30)     ' 2 neg. values, mirrors about its anchor point
    GraphicsWindow.FillEllipse(100,50, -30,-30)    ' 2 neg values, mirrors about its anchor point
    ell = Shapes.AddEllipse(0,0)                  ' zero size = currently invisible
    Shapes.Move(ell, 150,50)
    
    GraphicsWindow.DrawLine(0,100, GraphicsWindow.Width,100)
    'GraphicsWindow.PenWidth = 5
    GraphicsWindow.DrawRectangle(50,110, 0,0)      ' 2 zero values -> single 'point' in PenWidth
    GraphicsWindow.FillRectangle(50,120, 0,0)     ' 1 zero value = invisible, no line, no point
    rect = Shapes.AddRectangle(0,0)               ' zero size = currently invisible
    Shapes.Move(rect, 150,100)
    
    ' pump up the Shapes
    While "True"
      For wh = 0 To 100
        Controls.SetSize(ell, wh,wh)
        Controls.SetSize(rect, wh,wh)
        Program.Delay(20)
      EndFor
      Program.Delay(1000)
      For wh = 100 To 0 Step -1
        Controls.SetSize(ell, wh,wh)
        Controls.SetSize(rect, wh,wh)
        Program.Delay(20)
      EndFor
    EndWhile


    Friday, March 31, 2017 9:14 AM
    Answerer
  • hello very good program but the rectangles does not apear on window like the ellipses does
     before Animation there are two ellipses on window one drawn the other filled but there are
     no rectangles while the code for rectangle is there like the ellipses i hope you have understood
    the problem.                        mahreen miangul
    Saturday, April 01, 2017 2:01 PM
  • You mean the lines:

    1.)  GraphicsWindow.DrawRectangle(50,100, 0,0)      ' 2  zero values

      2 zero values -> shows a single 'point' in PenWidth (eg. default 2x2)

      but  GraphicsWindow.DrawRectangle(50,100, 0,10)   ' 1 zero value -> vertical line

       1 zero value -> shows a line along the other nonzero coordinate (in PenWidth)

    2.)  GraphicsWindow.FillRectangle(100,100, 0,0)     '  2 zero values

        both dimensions (width & height) have to be >0 to make a view (just like with Shapes.AddRectangle)

    See here and try yourself by changing the values for width and height and/or PenWidth

    GraphicsWindow.FontBold = ""
    GraphicsWindow.DrawText(30,50, "↓ DrawR..")
    
    'GraphicsWindow.PenWidth = 10
    GraphicsWindow.DrawRectangle(50,100, 0,0)      '  2 zero values -> single 'point' in PenWidth eg. default 2x2
    GraphicsWindow.DrawRectangle(50,150, 0,10)     ' 1 zero value -> line along the other non zero coordinate (in PenWidth)
    
    GraphicsWindow.DrawText(90,50, "↓ FillR..")
    GraphicsWindow.FillRectangle(100,100, 0,0)     '  already 1 zero value makes it invisible (ZERO dimension), no line, no point 
                                                   ' -> nothing to see unless both dimensions are > 0 !!
    GraphicsWindow.FillRectangle(100,150, 0,10)
    GraphicsWindow.FillRectangle(100,200, 10,20)  ' -> both dimensions (width & height) have to be defined to make a view
                                                  ' just like with Shapes.AddRectangle
    
    ' Marks
    GraphicsWindow.PenColor = "Red"
    GraphicsWindow.PenWidth = 2
    GraphicsWindow.DrawEllipse(30,80, 40,40)
    GraphicsWindow.DrawEllipse(30,130, 40,40)
    GraphicsWindow.DrawEllipse(80,80, 40,40)



    Saturday, April 01, 2017 8:27 PM
    Answerer
  • In program Animation and cannon why is the cannon not moving left or right by keys X and Z and not firing the ball by key F

    GraphicsWindow.KeyDown = moveCannon
    GraphicsWindow.Width = 1288
    GraphicsWindow.height = 666
    GraphicsWindow.top=0
    GraphicsWindow.left=0
    GraphicsWindow.BackgroundColor="blue"
    MakeSprite()
    dx=-5
    dy=0
    cannon1_x = 555
    cannon1_y = 544
    cannon = Shapes.AddRectangle(50,100)
    Shapes.Move(cannon, cannon1_x, cannon1_y)
    GraphicsWindow.BrushColor="Black"
    Ball=Shapes.AddEllipse(40,40)
    Shapes.Move(Ball,cannon1_x+5,cannon1_y+30)
    Shapes.HideShape(Ball)

    by=2  '  ball speed Y-direction
    Flag="False"
    by=2  '  ball speed Y-direction
    X=1

    GraphicsWindow.KeyDown = OnKeyDown
    While "True" '<------------
    TrainMove="True" '<------------

    While TrainMove '<------------
      For i=1 To 13
        Shapes.Move(ell[i],Shapes.GetLeft(ell[i])+ddx,shapes.GetTop(ell[i])+ddy)
        Shapes.Move(rec[i],Shapes.GetLeft(rec[i])+ddx,shapes.GetTop(rec[i])+ddy)
        Shapes.Move(Tri[i],Shapes.GetLeft(Tri[i])+ddx,shapes.GetTop(Tri[i])+ddy)
      EndFor
      If Shapes.GetLeft(ell[1])<-200 Then
        moveright()
      EndIf
      If Shapes.GetLeft(ell[1])>1200 then    'WhT
        ddx=-ddx                             'WhT
      EndIf                                  'WhT
      If shoot Then '<------------    
        TX= Shapes.GetLeft(Tri[4])+230 '<------------
        TY= Shapes.Gettop(Tri[4])+385 '<------------
        If bY<-100 then '<------------
          shoot="False"'<------------
        EndIf  '<-------
          Hit="True" '<------------
          TrainMove="False" '<------------
        EndIf  '<------------
      Program.Delay(20)
      endwhile
      Program.Delay(1500) '<------------
    endwhile

    Sub moveright
      el1y=shapes.GetTop(rec[9]) '<---------  
      ddy= Math.GetRandomNumber(Math.Abs(300-el1y))-el1y
      ddx=-ddx                                'WhT
      For i=1 To 13
        Shapes.Move(ell[i],Shapes.GetLeft(ell[i])+ddx,shapes.GetTop(ell[i])+ddy)  'WhT   changed 1200 to ddx
        Shapes.Move(rec[i],Shapes.GetLeft(rec[i])+ddx,shapes.GetTop(rec[i])+ddy)  'WhT  changed 1200 to ddx
        Shapes.Move(Tri[i],Shapes.GetLeft(Tri[i])+ddx,shapes.GetTop(Tri[i])+ddy)  'haroon rashid  changed 1200 to ddx
      EndFor
      ddy=0
    EndSub


    While 1=1
        X=-X  '  reverse moving direction
      If flag="True" Then
        bx= angle/math.Abs(angle+0.000001)  '  ball speed X-direction // 0.000001 to avoid zero division
        Shapes.Move(ball,shapes.GetLeft(ball)+bx,shapes.Gettop(ball)-by)
        If Shapes.GetTop(ball)<-100 then   '  ball Y-position is <-100
          Shapes.HideShape(Ball)           '  ball  disappear
          Shapes.Move(Ball,cannon1_x+5,cannon1_y+30)  '  ball moves to cannon position
          Flag="False"
        EndIf
      EndIf
      Program.Delay(10)
    endwhile

    Sub MakeSprite
      ' 7 Rectangle
      GraphicsWindow.BrushColor="green"
      rec[1] =  Shapes.AddRectangle(50,8)  '<--  
      Shapes.Move(rec[1], 440,115)
      rec[2] =  Shapes.AddRectangle(50,8)  '<--  
      Shapes.Move(rec[2], 440,140)
      GraphicsWindow.brushcolor = "sienna"
      rec[3] =  Shapes.AddRectangle(60,6)  '<--  
      Shapes.Move(rec[3], 355,120)
      rec[4] =  Shapes.AddRectangle(60,6)  '<--  
      Shapes.Move(rec[4], 355,138)
      GraphicsWindow.brushcolor = "darkgoldenrod"
      rec[5] =  Shapes.AddRectangle(100,22)  '<--  
      Shapes.Move(rec[5], 400,120)
      ' 7 Ellipses
      GraphicsWindow.BrushColor="bisque"
      ell[1] =  Shapes.AddEllipse(30,20)
      Shapes.Move(ell[1], 520,90)
      ell[2] =  Shapes.AddEllipse(30,20)
      Shapes.Move(ell[2], 520,150)
       GraphicsWindow.BrushColor="purple"
      ell[3] =  Shapes.AddEllipse(70,70)
      Shapes.Move(ell[3], 500,95)
      GraphicsWindow.BrushColor="sienna"
      ell[4] =  Shapes.AddEllipse(30,10)
      Shapes.Move(ell[4], 520,120)
      GraphicsWindow.BrushColor="pink"
      ell[5] =  Shapes.AddEllipse(10,30)
      Shapes.Move(ell[5], 510,115)
      GraphicsWindow.BrushColor="cyan"
      ell[6] =  Shapes.AddEllipse(30,20)
      Shapes.Move(ell[6], 530,102)
      ell[7] =  Shapes.AddEllipse(30,20)
      Shapes.Move(ell[7], 530,128)
      ' 1 triangles
      GraphicsWindow.BrushColor="gold"
      tri[1] =  Shapes.Addtriangle(566,100,611,130,566,160)
      Shapes.Move(tri[1], 0,0)

      chrome=GraphicsWindow.getcolorfromrgb(215,219,213)
        GraphicsWindow.brushcolor=chrome
      tri[3] =  Shapes.Addtriangle(585,405,585,420,450,390)
      Shapes.Move(tri[3], 0,0)
        GraphicsWindow.BrushColor="#000000"
      tri[4] =  Shapes.Addtriangle(350,445,230,445,350,385)
      Shapes.Move(tri[4], 0,0)

      ' piston cylinder

      GraphicsWindow.brushcolor=chrome
      rec[12] =  Shapes.Addrectangle(150,20)
      Shapes.Move(rec[12], 585,405)

      rec[13] =  Shapes.Addrectangle(90,30)
      Shapes.Move(rec[13], 360,380)
    EndSub

    Sub moveCannon
      If flag="False" Then
        If GraphicsWindow.LastKey = "X" Then
          angle=angle+5
          Shapes.Rotate(cannon,angle)
        ElseIf GraphicsWindow.LastKey = "Z" Then
          angle=angle-5
          Shapes.Rotate(cannon,angle)
        ElseIf GraphicsWindow.LastKey="F" then
          flag="True"
          Shapes.ShowShape(Ball)
        EndIf
      endif
    EndSub

    '  keys    S, W, A, T, F , SpaceBar works
    Sub OnKeyDown
      key= GraphicsWindow.LastKey
      If key="S" Then
        ddx=4
      ElseIf Key="W"then
        ddx=-4
      ElseIf Key="A"then
        ddy=4
      ElseIf key="T"Then
        ddy=-4
      ElseIf key="Space" Then
        ddx=0     'WhT
        ddy=0
        EndIf
      endsub

    with thanks                                       mahreen miangul

           
    Sunday, April 02, 2017 1:45 PM
  • You have TWO   GraphicWindow.KeyDown statements. The last one executed is in use, so the first (moveCannon) is not executed on KeyDown.

    Put all lastKey statement in one  subroutine and set flags on what to do in the main loop.

    ****edit***

    Also you hace TWO non-ending While-loops. The second in never reached.


    Jan [ WhTurner ] The Netherlands



    Sunday, April 02, 2017 2:12 PM
    Answerer
  • Animation is working the Cannon is not this is the best i could do ID TMM885               mussa-maina

                                                        mahreen miangul

    Tuesday, April 04, 2017 5:15 AM
  • Animation is working the Cannon is not this is the best i could do ID TMM885               mussa-maina

                                                        mahreen miangul

    Your program flows as follows.

    1)GraphicsWindow condition
    2)set Keydown event  // moveCannon
    3)MakeSprite()       //  <--18)  This moves UpDownLeftRight
    4)make a Cannon shape
    5)make a ball shape  // Hide mode
    6)Draw Hill,Lake,Sun //Graphics
    7)make a Snowglobe shape
    8)Draw Text          //mahreen miangul! mussa-maina! haroon rashid!
    9)make Tree shapes        <---21)
    10)make a House shape     <---19)
    11)make ball shapes  //10 apples  <---20)
    12)make Duck shapes  // 4 ducks  <---13)

    13)sub add_shapes
    14)set Keydown event // OnkeyDown
    15)while loop
       Trainmove ...  this is for Sprite moving //move right/Left/Up/Down
                      collision check is not completed

    16)sub moveright
    17)while loop
       if flag="True"     // if "F" key is pressed,  ball  moves to top
     
    18)sub Makesprite
    19)sub house_init
    20)sub balls_init
    21)sub Tree_init
    22)sub Duck_init
    23)sub OnkeyDown   //  S W A T Space keys
    24)sub moveCannon  //  X Z F keys

    as  WhTurner33 mentioned, there are some problems. 
     
    (1) 2 keydown event.    2) and 14) for 23) and 24)
       you should merge them.
    (2) 2 while loop.   15) and 17)
       you should merge them.

    (3) collision check is not completed.
      What is the target shape which ball hits?
      Tri[4] is the target??  or ell[3]? or other shape?
     
      and you'd better add collision check program .
          TX= Shapes.GetLeft(Tri[4])+230'<--
          TY= Shapes.Gettop(Tri[4])+385 '<--
          If bY<-100 then
            shoot="False"
          EndIf 
         // collision check program
         // should be written here  '<--
         //
          Hit="True"
          TrainMove="False"

    (4) One more problem

        ball for cannon and ball array name for apples are same. so evenif you press "F" , ball doesnt appear.

       rename ball array name to apple(for example).  <--  20) 

        sub balls_init --> sub Apples_init

        ball[ ] -->  Apple[ ]

       and chage 11) as below.

      ' 3apple
      Apples_init()
      shape=apple
      Name="Apple"

    Tuesday, April 04, 2017 2:14 PM
    Answerer
  • hello and God bless you i think i am getting somewhere ID BTD342 Sprite is animating and moving cannon is
    moving and firing but now the ball is not moving with the connon and also the ball is not hitting the sprite
    i think jibba jabba is doing it in DUCK SHOOT ID CTJ510-0 but his duck is colorless i have tried but cant color
    it with thanks

                                                               mahreen miangul
    Tuesday, April 11, 2017 8:50 AM
  • By adding the following line as first line in the Sub AddDuck you can give the duck any color you want:

      GraphicsWindow.BrushColor="Green"

    Or by adding the liones with <<=== on the right places, a multicolored duck:

      DS[4] = "W=22;H=5;RX=77;RY=0;R=-0"  'BEAK
      col="1=blue;2=green;3=yellow;4=red"      ''<<===
    EndSub
    
    Sub AddDuck
      For i = 1 To 4
       GraphicsWindow.BrushColor=col[i]      ''<<===
    

     

    Jan [ WhTurner ] The Netherlands


    Tuesday, April 11, 2017 10:14 AM
    Answerer
  • hello and God bless you i think i am getting somewhere ID BTD342 Sprite is animating and moving cannon is
    moving and firing but now the ball is not moving with the connon and also the ball is not hitting the sprite
    i think jibba jabba is doing it in DUCK SHOOT ID CTJ510-0 but his duck is colorless i have tried but cant color
    it with thanks

                                                               mahreen miangul

     you posted resembled program QST393 in  Challenge of the Month - April 2017 .

    See  QST393-0 .

    you did merge  2 keydown event.

    (2) 2 while loop.   15) and 17)   merged

    (3) collision check is added.   in this case ball hits face. 

                                    
    Sunday, April 16, 2017 12:15 AM
    Answerer
  • hello now the duck is all black no color

              thankyou                                            mahreen miangul

    Friday, April 21, 2017 11:17 AM
  • hello, Yandee Man ID JRP437 mahreen miangul version ID GFS079 Yandee Man moving across the Screen ID QRB861 the only diffrence is that the orignal is combing opacity in the blinking with thanks

                                                                                                    mahreen miangul

    Friday, April 21, 2017 11:29 AM
  • hello the duck is now coming in one color now but wont take multiple colors

                                                                                        mahreen miangul

    Sunday, April 23, 2017 9:56 AM