none
mahreen miangul MaRch 2017

    Question

  • hello Program ID BGB172 very nice and simple tutotrial thank you  am posting ID WTX888 i have done what was in your tutorial i have tried to move the sprite Up by key S and Down by key T but but keys A and S movement is also disturbed what am i doing wrong  with thanks              with love from mussa-maina

                                                                                         mahreen miangul

    Monday, February 27, 2017 3:29 PM

Answers

  • Hi Mussamaina !

    Here is a version that work: WTX888-0

    press W to move down

    press Z to move up

    press A to move left

    press S to move right

    press S+W will move the object right and down at the same time


    Monday, February 27, 2017 4:12 PM
    Answerer

All replies

  • Hi Mussamaina !

    Here is a version that work: WTX888-0

    press W to move down

    press Z to move up

    press A to move left

    press S to move right

    press S+W will move the object right and down at the same time


    Monday, February 27, 2017 4:12 PM
    Answerer
  • hello every body program ID BGB172 was excelent thankyou program ID WTX888-0 was very good but a little confusing here is a
    a program copied from both of them keyS is for Right movement Key W for Left movement (X-axs-movement) key A is for Up movement
    Key T is for Down movement (Y-axs movement) Key F is for fire Cannon and SpaceBar is to stop the Sprite(Shape)
    Animation KeyBoard mahreen miangul

    ' mahreen miagul MaRch 2017
    ' Keys S-W-A-T & F
    ' SpaceBar
    GraphicsWindow.Width = 1288
    GraphicsWindow.Height = 688
    GraphicsWindow.BackgroundColor = "rosybrown"
    GraphicsWindow.KeyDown=Onkeydown
    shape_init() '   Cycle and Tree Shapes data
    N=0
    M=0
    shapes_add() '  Cycle Shape
    N=1
    For M=1 to 8
      shapes_add()  '  Tree Shape
    endfor
    'Animate Cycle
    dZ = 0.1
    zoom = 1
    ddx=4
    ddy=4
    While 0=0
      zoom = zoom - dZ
      For i = 1 To Array.GetItemCount(shape[0])
        If Array.ContainsValue(shape[0][i], "eye") Then
          Shapes.Zoom(shp[0][i], 1, zoom)
        ElseIf Array.ContainsValue(shape[0][i], "mouth") Then
          Shapes.Zoom(shp[0][i], zoom, zoom)
        EndIf
        shapes.Move(shp[0][i],shapes.GetLeft(shp[0][i])+ddx,shapes.Gettop(shp[0][i])+ddy)
      shapes.Move(shp[0][i],shapes.GetLeft(shp[0][i]),shapes.Gettop(shp[0][i]))
    EndFor
      If zoom = 0 Or zoom = 1 Then
        dZ = -dZ
      EndIf
      Program.Delay(100)
    EndWhile

    Sub Onkeydown
      key= GraphicsWindow.LastKey
      If key="S" Then
        ddx=4
         elseIf key="W" Then
        ddy=4
      ElseIf key="A"Then
        ddx=-4
         elseIf key="Z" Then
        ddy=-4
      ElseIf key="Space" Then
        ddx=0
      EndIf
     
    EndSub

    Sub shapes_add
      ss=s[M]    '  <--------- scale  data
      for i=1 To Array.GetItemCount(shape[N]) 
        GraphicsWindow.PenWidth = shape[N][i]["pw"]
        GraphicsWindow.BrushColor = shape[N][i]["bc"]
        GraphicsWindow.penColor = shape[N][i]["pc"]
        If shape[N][i]["func"]="ell" Then
          shp[M][i] = Shapes.AddEllipse(shape[N][i]["width"]*ss, shape[N][i]["height"]*ss)
        ElseIf shape[N][i]["func"]="rect" Then
          shp[M][i] = Shapes.AddRectangle(shape[N][i]["width"]*ss, shape[N][i]["height"]*ss)
        ElseIf shape[N][i]["func"]="tri" Then
          shp[M][i] = Shapes.Addtriangle(shape[N][i]["x1"]*ss, shape[N][i]["y1"]*ss,shape[N][i]["x2"]*ss, shape[N][i]["y2"]*ss, shape[N][i]["x3"]*ss, shape[N][i]["y3"]*ss)
        EndIf
        Shapes.Animate(shp[M][i], shape[N][i]["x"]*ss+shX[M], shape[N][i]["y"]*ss+shY[M], 500)
      EndFor
    EndSub
    Sub shape_init
      ' Data Cycle
      ' Table key: W = width; H = height; X = X rel to the body; Y = Y rel to body; R = rotate angle"
      shape[0][1] = "func=ell;x=520;y=90;width=30;height=20;bc=bisque;tag=ear"'left
      shape[0][2] = "func=ell;x=520;y=150;width=30;height=20;bc=bisque;tag=ear"'right
      shape[0][3] = "func=ell;x=500;y=95;width=70;height=70;bc=purple;pc=darkslategray;pW=2" 'face
      shape[0][4] = "func=ell;x=520;y=120;width=30;height=10;bc=sienna;tag=nose"
      shape[0][5] = "func=ell;x=510;y=115;width=10;height=30;bc=pink;tag=mouth"
      shape[0][6] = "func=ell;x=530;y=102;width=30;height=20;bc=cyan;pc=darkslategray;pW=2;tag=eye"'eye1
      shape[0][7] = "func=ell;x=530;y=128;width=30;height=20;bc=cyan;pc=darkslategray;pW=2;tag=eye"'eye2
      shape[0][8] = "func=rect;x=440;y=115;width=50;height=8;bc=green;tag=mouth"'hand1
      shape[0][9] = "func=rect;x=440;y=140;width=50;height=8;bc=green;tag=mouth"'hand2
      shape[0][10] = "func=rect;x=355;y=120;width=60;height=6;bc=sienna;tag=mouth"'leg1
      shape[0][11] = "func=rect;x=355;y=138;width=60;height=6;bc=sienna;tag=mouth"'leg2
      shape[0][12] = "func=rect;x=400;y=120;width=100;height=22;bc=darkgoldenrod;pc=darkslategray;pW=2"'body
      shape[0][13] = "func=tri;x1=566;y1=100;x2=611;y2=130;x3=566;y3=160;bc=gold;angle=0;pw=2;tag=head"

      '  Data Tree
      shape[1][1]="func=ell;X=0;Y=188;width=200;height=140;bc=Green;pc=Green;pw=2"
      shape[1][2]="func=ell;X=10;Y=277;width=80;height=60;bc=Green;pc=Green;pw=2
      shape[1][3]="func=ell;X=4;Y=255;width=80;height=70;bc=Green;pc=Green;pw=2
      shape[1][4]="func=ell;X=0;Y=191;width=80;height=80;bc=Green;pc=Green;pw=2
      shape[1][5]="func=ell;X=40;Y=177;width=80;height=80;bc=Green;pc=Green;pw=2
      shape[1][6]="func=ell;X=100;Y=177;width=120;height=80;bc=Green;pc=Green;pw=2
      shape[1][7]="func=ell;X=130;Y=240;width=100;height=80;bc=Green;pc=Green;pw=2
      shape[1][8]="func=ell;X=130;Y=260;width=100;height=80;bc=Green;pc=Green;pw=2
      shape[1][9]="func=rect;X=80;Y=322;width=60;height=100;bc=saddlebrown;pc=darkslatgray;pw=2
      shape[1][10]="func=tri;X1=140;Y1=262;X2=110;Y2=322;X3=140;Y3=322;bc=saddlebrown;pc=darkslatgray;pw=0
      shape[1][11]="func=tri;X1=140;Y1=262;X2=170;Y2=262;X3=140;Y3=322;bc=saddlebrown;pc=darkslatgray;pw=0
      shape[1][12]="func=tri;X1=50;Y1=262;X2=96;Y2=262;X3=80;Y3=322;bc=saddlebrown;pc=darkslatgray;pw=0
      shape[1][13]="func=tri;X1=96;Y1=262;X2=80;Y2=322;X3=126;Y3=322;bc=saddlebrown;pc=darkslatgray;pw=0
      '  scale and   start XY position
      s   = "0=1.1;1=0.8;2=0.8;3=0.8;4=0.8;5=0.8;6=0.8;7=0.8;8=0.8"
      shX = "0=0;1=10;2=160;3=655;4=822;5=988;6=1100;7=370;8=420"
      shY = "0=0;1=188;2=180;3=112;4=88;5=102;6=122;7=200;8=211"
    endsub

              please upgrad and Edit the above program so that i a can compare both programs and learn where and what am i doing wrong please make it simple and short if posible  not if unnesisarly
    with thanks and regards             mahreen miangul

                                                            with love from mussa-maina
    Wednesday, March 01, 2017 7:07 AM
  • mussamaina,

    For your program to work comment out the following in your while loop:

      'shapes.Move(shp[0][i],shapes.GetLeft(shp[0][i]),shapes.Gettop(shp[0][i]))

    It would seem that this line is eliminating the ddx and ddy settings before they can take effect which you have put in the line just before this.

    Also for the spaceship to stop movement totally when you press the spacebar I put in:

        ddx=0
        ddy=0

    With these changes you should be able to move the spaceship in any direction and stop total movement of the ship.


    JR


    • Edited by jricestk Wednesday, March 01, 2017 5:23 PM Edit
    • Proposed as answer by YLedEditor Thursday, March 02, 2017 2:36 PM
    Wednesday, March 01, 2017 4:42 PM
  • mussa-maina, if want to do "Key F is for fire Cannon",  see ZWZ092-4

     <make cannon>

    <collision check>

    https://social.msdn.microsoft.com/Forums/en-US/e7ee437c-5281-4ed3-93dd-a4bb8460af24/mahreen-miangul-february-2017?forum=smallbasic
    • Edited by NaochanONEditor Wednesday, March 01, 2017 11:33 PM add comment
    • Proposed as answer by YLedEditor Thursday, March 02, 2017 2:36 PM
    Wednesday, March 01, 2017 11:30 PM
    Answerer
  • some updates: WTX888-1

    • changed controls by arrow keys
    • colors changed and corrected
    Saturday, March 04, 2017 5:09 AM
  • hello everyBody program Animation & KeyBoard ID TCL748 Keys S-W-A-T all are moving the Cycle left and right on the screen keys S-W should move the Cycle left right and keys A-T should move the Cycle Up and Down Key F is to fire which is not working and the house is also multiple showing the house should be one .thanking you             mahreen miangul                mussa-maina

    Saturday, March 04, 2017 1:07 PM
  • mussamaina,

    To get the cannon working just below the sub onkeydown set shoot to "False". You needed to initialize the variable. I changed the position for the move ball in the while loop to the following so you can see it. If you keep hitting the F key you will see the triangle change color. Why not use an ellipse command for ball?

       shoot = "False"

        Shapes.Move(ball,100,100)

    Also, A and T do not work in your program because you are setting the wrong variable. It should be ddY not ddX. When you change these you also need to set ddY to 0 when you push the spacebar. You are doing it for ddX, but not ddY.

    Good graphics!


    JR


    • Edited by jricestk Saturday, March 04, 2017 3:38 PM
    Saturday, March 04, 2017 3:34 PM
  • hello everybody program ID RZR554 turtle draws mussa maina  but cant draw the S will someone help the  Turtle thankyou ---------------------------------from mussa-maina with love
                                                                                 mahreen miangul

    Wednesday, March 08, 2017 7:51 AM
  • hello everybody program ID TRP429 when cannon fired it always hit the black triangle why does it not hit anything other then the black triangle help needed thank you

                                      mussa-maina ----------------------mahreen miangul

    Wednesday, March 08, 2017 1:36 PM
  • hello everybody program ID TRP429 when cannon fired it always hit the black triangle why does it not hit anything other then the black triangle help needed thank you

                                      mussa-maina ----------------------mahreen miangul

    see this thread.

    https://social.msdn.microsoft.com/Forums/en-US/d42060cc-2d76-4f41-b1d3-d188343b74fa/challenge-of-the-month-march-2017?forum=smallbasic

    Thursday, March 09, 2017 3:18 AM
    Answerer
  • Face Drawing NSM030 mahreen miangul

                                                              mahreen miangul

    Sunday, March 12, 2017 1:19 PM
  • face Chalk Drawing ID GMX344 orignal by Nonki -----------------mahreen miangul

    Friday, March 17, 2017 4:50 AM