none
mahreen miangul febrUary 2017

    Question

  • hello everybody hope all of you are well and in good health programs Blinking Eyes ID BDR631 and Chalk Colors ID PCC484 were posted now i am putting a program ID ZMZ638 on the forum the cycle is moving from left to right would like to move it from right to left will some one help

    ' mahreen miangul
    ' Animation Event
    ' FebrUary 2017
    GraphicsWindow.Title = "ArrowKeys Event"
    GraphicsWindow.Width = "1080"
    GraphicsWindow.Height = "420"
    GraphicsWindow.BackgroundColor = "LightYellow"
    GraphicsWindow.FontName = "Times New Roman"
    GraphicsWindow.FontSize = 120
     GraphicsWindow.FontItalic = "True"

     GraphicsWindow.BrushColor = "Silver"    ' Text shadow color
      GraphicsWindow.DrawText(5, 5, "mahreen miangul!") ' Shadow position/text

     GraphicsWindow.BrushColor = "RosyBrown" ' Text color
     GraphicsWindow.DrawText(0, 0, "mahreen miangul!") ' Position and text
    MakeSprite()
    ddx=-5
    ddy=0

    While "True"
      For i=1 To 5
        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)
      EndFor
      If Shapes.GetLeft(ell[1])<-200 Then
        moveright()
      EndIf
      Program.Delay(20)
    endwhile

    Sub moveright
      el1y=shapes.GetTop(ell[1])
      ddy= Math.GetRandomNumber(Math.Abs(300-el1y))-el1y
      For i=1 To 5
        Shapes.Move(ell[i],Shapes.GetLeft(ell[i])+1200,shapes.GetTop(ell[i])+ddy)
        Shapes.Move(rec[i],Shapes.GetLeft(rec[i])+1200,shapes.GetTop(rec[i])+ddy)
      EndFor
      ddy=0
    EndSub

    Sub MakeSprite
      ' 1 Rectangle
      GraphicsWindow.BrushColor="darkgoldenrod"
      rec[1] =  Shapes.AddRectangle(100,22)  '<--  body
      Shapes.Move(rec[1], 400,120)
      ' 5 Ellipses
        GraphicsWindow.BrushColor="purple"
      ell[1] =  Shapes.AddEllipse(70,70)
      Shapes.Move(ell[1], 500,95)
      GraphicsWindow.BrushColor="cyan"
      ell[2] =  Shapes.AddEllipse(30,20)
      Shapes.Move(ell[2], 524,128)
      GraphicsWindow.BrushColor="cyan"
      ell[3] =  Shapes.AddEllipse(30,20)
      Shapes.Move(ell[3], 524,102)
      GraphicsWindow.BrushColor="sienna"
      ell[4] =  Shapes.AddEllipse(60,6)
      Shapes.Move(ell[4], 360,122)
        GraphicsWindow.BrushColor="sienna"
      ell[5] =  Shapes.AddEllipse(60,6)
      Shapes.Move(ell[5], 360,136)
    EndSub

     
    Monday, February 13, 2017 1:20 PM

Answers

  • Here is your program with the following changes:

    - your figure moves left to right and back.

    - on pressing one of the keys S W A or P, the figure goes in the other direction.

    I added 11 lines and changed two line, they are marked with WhT

    ' mahreen miangul
    ' Animation Event
    ' FebrUary 2017
    GraphicsWindow.Title = "ArrowKeys Event"
    GraphicsWindow.Width = "1080"
    GraphicsWindow.Height = "420"
    GraphicsWindow.BackgroundColor = "LightYellow"
    GraphicsWindow.FontName = "Times New Roman"
    GraphicsWindow.FontSize = 120
    GraphicsWindow.FontItalic = "True"
    
    GraphicsWindow.BrushColor = "Silver"    ' Text shadow color
    GraphicsWindow.DrawText(5, 5, "mahreen miangul!") ' Shadow position/text
    
    GraphicsWindow.BrushColor = "RosyBrown" ' Text color
    GraphicsWindow.DrawText(0, 0, "mahreen miangul!") ' Position and text
    GraphicsWindow.KeyDown=KeyD             'WhT
    MakeSprite()
    ddx=-5
    ddy=0
    
    While "True"
      For i=1 To 5
        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)
      EndFor
      If Shapes.GetLeft(ell[1])<-200 Then 
        moveright()
      EndIf
      If Shapes.GetLeft(ell[1])>1200 then   'WhT
        ddx=-ddx                            'WhT
      EndIf                                 'WhT
      Program.Delay(20)
    endwhile
    Sub KeyD                                'WhT
      key=GraphicsWindow.LastKey             'WhT
      If key="S" or key="W" Or key="A" Or key="P" then    'WhT
        ddx=-ddx                             'WhT
      EndIf                                  'WhT   
    EndSub                                   'WhT
    
    Sub moveright
      el1y=shapes.GetTop(ell[1])
      ddy= Math.GetRandomNumber(Math.Abs(300-el1y))-el1y
      ddx=-ddx                               'WhT
      For i=1 To 5
        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
      EndFor
      ddy=0
    EndSub
    
    Sub MakeSprite
      ' 1 Rectangle
      GraphicsWindow.BrushColor="darkgoldenrod"
      rec[1] =  Shapes.AddRectangle(100,22)  '<--  body
      Shapes.Move(rec[1], 400,120)
      ' 5 Ellipses
      GraphicsWindow.BrushColor="purple"
      ell[1] =  Shapes.AddEllipse(70,70)
      Shapes.Move(ell[1], 500,95)
      GraphicsWindow.BrushColor="cyan"
      ell[2] =  Shapes.AddEllipse(30,20)
      Shapes.Move(ell[2], 524,128)
      GraphicsWindow.BrushColor="cyan"
      ell[3] =  Shapes.AddEllipse(30,20)
      Shapes.Move(ell[3], 524,102)
      GraphicsWindow.BrushColor="sienna"
      ell[4] =  Shapes.AddEllipse(60,6)
      Shapes.Move(ell[4], 360,122)
      GraphicsWindow.BrushColor="sienna"
      ell[5] =  Shapes.AddEllipse(60,6)
      Shapes.Move(ell[5], 360,136)
    EndSub
    


    Jan [ WhTurner ] The Netherlands

    • Proposed as answer by YLedEditor Monday, February 13, 2017 9:23 PM
    • Marked as answer by mussamaina Tuesday, February 14, 2017 5:57 AM
    Monday, February 13, 2017 4:26 PM
    Answerer
  • mussa maina  nice program.

    rec[9] is the top shape.

    el1y=shapes.GetTop(rec[9]) '<---------  ell[1] to rec[9]

    • Marked as answer by mussamaina Thursday, February 16, 2017 10:44 AM
    Wednesday, February 15, 2017 11:39 PM
    Answerer
  • mussa-maina    how about this. 

    If "B" press ball  moves to top, if ball hits tri[4](front of train), train stops.

    ball added  when ball  frame out.

      

    ZWZ092-3  '<----* continuously works.



    • Edited by NaochanONEditor Friday, February 17, 2017 3:13 AM
    • Marked as answer by mussamaina Friday, February 17, 2017 11:15 AM
    Friday, February 17, 2017 3:08 AM
    Answerer

All replies

  • You have to make you wishes clearer.

    - when do you want to move from left to right?

    1. after reaching the left side or

    2. on the press of a key

    Or only to move from left to right?


    Jan [ WhTurner ] The Netherlands

    Monday, February 13, 2017 2:11 PM
    Answerer
  • hello with good wishes to turn the cycle on pressing keys-S-W-A or P with thanks

           with love from mussa maina------------------------mahreen miangul

    Monday, February 13, 2017 2:22 PM
  • Here is your program with the following changes:

    - your figure moves left to right and back.

    - on pressing one of the keys S W A or P, the figure goes in the other direction.

    I added 11 lines and changed two line, they are marked with WhT

    ' mahreen miangul
    ' Animation Event
    ' FebrUary 2017
    GraphicsWindow.Title = "ArrowKeys Event"
    GraphicsWindow.Width = "1080"
    GraphicsWindow.Height = "420"
    GraphicsWindow.BackgroundColor = "LightYellow"
    GraphicsWindow.FontName = "Times New Roman"
    GraphicsWindow.FontSize = 120
    GraphicsWindow.FontItalic = "True"
    
    GraphicsWindow.BrushColor = "Silver"    ' Text shadow color
    GraphicsWindow.DrawText(5, 5, "mahreen miangul!") ' Shadow position/text
    
    GraphicsWindow.BrushColor = "RosyBrown" ' Text color
    GraphicsWindow.DrawText(0, 0, "mahreen miangul!") ' Position and text
    GraphicsWindow.KeyDown=KeyD             'WhT
    MakeSprite()
    ddx=-5
    ddy=0
    
    While "True"
      For i=1 To 5
        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)
      EndFor
      If Shapes.GetLeft(ell[1])<-200 Then 
        moveright()
      EndIf
      If Shapes.GetLeft(ell[1])>1200 then   'WhT
        ddx=-ddx                            'WhT
      EndIf                                 'WhT
      Program.Delay(20)
    endwhile
    Sub KeyD                                'WhT
      key=GraphicsWindow.LastKey             'WhT
      If key="S" or key="W" Or key="A" Or key="P" then    'WhT
        ddx=-ddx                             'WhT
      EndIf                                  'WhT   
    EndSub                                   'WhT
    
    Sub moveright
      el1y=shapes.GetTop(ell[1])
      ddy= Math.GetRandomNumber(Math.Abs(300-el1y))-el1y
      ddx=-ddx                               'WhT
      For i=1 To 5
        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
      EndFor
      ddy=0
    EndSub
    
    Sub MakeSprite
      ' 1 Rectangle
      GraphicsWindow.BrushColor="darkgoldenrod"
      rec[1] =  Shapes.AddRectangle(100,22)  '<--  body
      Shapes.Move(rec[1], 400,120)
      ' 5 Ellipses
      GraphicsWindow.BrushColor="purple"
      ell[1] =  Shapes.AddEllipse(70,70)
      Shapes.Move(ell[1], 500,95)
      GraphicsWindow.BrushColor="cyan"
      ell[2] =  Shapes.AddEllipse(30,20)
      Shapes.Move(ell[2], 524,128)
      GraphicsWindow.BrushColor="cyan"
      ell[3] =  Shapes.AddEllipse(30,20)
      Shapes.Move(ell[3], 524,102)
      GraphicsWindow.BrushColor="sienna"
      ell[4] =  Shapes.AddEllipse(60,6)
      Shapes.Move(ell[4], 360,122)
      GraphicsWindow.BrushColor="sienna"
      ell[5] =  Shapes.AddEllipse(60,6)
      Shapes.Move(ell[5], 360,136)
    EndSub
    


    Jan [ WhTurner ] The Netherlands

    • Proposed as answer by YLedEditor Monday, February 13, 2017 9:23 PM
    • Marked as answer by mussamaina Tuesday, February 14, 2017 5:57 AM
    Monday, February 13, 2017 4:26 PM
    Answerer
  • hello everybody a very good and simple program easy to understand and am busy with it from the moment recived it thankyou  with best wishes

              with love from mussa-maina
                                mahreen miangul

             


    • Edited by mussamaina Tuesday, February 14, 2017 1:15 PM spelling mistakes
    Tuesday, February 14, 2017 1:12 PM
  • hello every body program Car Image mussa- maina ID TCH804 drawing Sprite and another program with thanks to WhT Animation Car Image by S-W-A-T ID ZWZ092  your program was perfect in my program the sprite goes out of the window
      with love from mussa maina

    Wednesday, February 15, 2017 12:39 PM
  • mussa maina  nice program.

    rec[9] is the top shape.

    el1y=shapes.GetTop(rec[9]) '<---------  ell[1] to rec[9]

    • Marked as answer by mussamaina Thursday, February 16, 2017 10:44 AM
    Wednesday, February 15, 2017 11:39 PM
    Answerer
  • ThankYou NaochanON from mussa-maina with Love

                                        mahreen miangul

    Thursday, February 16, 2017 10:43 AM
  • Hi Mussamaina !

    great program !

    program: ZWZ092-0

    I have a little bit modified your train, add big wheels, with piston and valve gear,

    Steam locomotive, like this one:


    • Edited by YLedEditor Friday, February 17, 2017 4:48 PM linking image to not repeat
    Thursday, February 16, 2017 12:51 PM
    Answerer
  • hello everybody i have added key B Event to hit the train by pressing Key B but now Keys S-W-A-T are not wrking and the triangles are not hiting the Sprite

    ' Moving Sprite on Window by Keys S-W-A-T
    ' mahreen miangul
    ' FebrUary 2017
    GraphicsWindow.Title = "S-W-A-T"
    GraphicsWindow.Width = "1200"
    GraphicsWindow.Height = "700"
    GraphicsWindow.top=0
    GraphicsWindow.left=0

    GraphicsWindow.BackgroundColor = "LightYellow"
    GraphicsWindow.FontName = "Times New Roman"
    GraphicsWindow.FontSize = 120
    GraphicsWindow.FontItalic = "True"

    GraphicsWindow.BrushColor = "Silver"    ' Text shadow color
    GraphicsWindow.DrawText(5, 5, "mahreen miangul!") ' Shadow position/text

    GraphicsWindow.BrushColor = "RosyBrown" ' Text color
    GraphicsWindow.DrawText(0, 0, "mahreen miangul!") ' Position and text
    GraphicsWindow.KeyDown=KeyDown           ' haroon rashid
    MakeSprite()
    ddx=-5
    ddy=0

     GraphicsWindow.KeyDown = OnKeyDown

    While "True"
      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
      Program.Delay(20)
    endwhile
    Sub KeyDown                               ' haroon rashid
      key=GraphicsWindow.LastKey              'WhT
      If key="S" or key="W" Or key="A" Or key="T" then    'hr
        ddx=-ddx                              'WhT
      EndIf                                   'WhT
    EndSub                                    'WhT

    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

    Sub MakeSprite
      ' 7 Rectangle
      GraphicsWindow.BrushColor="deepskyblue"
      rec[1] =  Shapes.AddRectangle(240,150)  '<--  
      Shapes.Move(rec[1], 420,200)
      GraphicsWindow.brushcolor = "yellow"
      rec[2] =  Shapes.AddRectangle(400,45)  '<--  
      Shapes.Move(rec[2], 349,370)
      rec[3] =  Shapes.AddRectangle(88,250)  '<--  
      Shapes.Move(rec[3], 660,120)
      GraphicsWindow.brushcolor = "crimson"
      rec[4] =  Shapes.AddRectangle(30,70)  '<--  
      Shapes.Move(rec[4], 440,130)
      rec[5] =  Shapes.AddRectangle(50,70)  '<--  
      Shapes.Move(rec[5], 680,160)
      rec[6] =  Shapes.AddRectangle(70,30)  '<--  
      Shapes.Move(rec[6], 747,240)
      GraphicsWindow.brushcolor = "darkslategray"
      rec[7] =  Shapes.Addrectangle(400,20)
      Shapes.Move(rec[7], 349,350)
      rec[8] =  Shapes.Addrectangle(40,55)
      Shapes.Move(rec[8], 310,390)
      rec[9] =  Shapes.Addrectangle(80,20)
      Shapes.Move(rec[9], 415,110)
      rec[10] =  Shapes.Addrectangle(140,20)
      Shapes.Move(rec[10], 630,110)
      rec[11] =  Shapes.Addrectangle(20,70)
      Shapes.Move(rec[11], 800,220)


      ' 5 Ellipses
      GraphicsWindow.BrushColor="yellow"
      ell[1] =  Shapes.AddEllipse(50,50)
      Shapes.Move(ell[1], 355,400)
      ell[2] =  Shapes.AddEllipse(50,50)
      Shapes.Move(ell[2], 430,400)
      ell[3] =  Shapes.AddEllipse(120,120)
      Shapes.Move(ell[3], 520,335)
      ell[4] =  Shapes.AddEllipse(120,120)
      Shapes.Move(ell[4], 650,335)
      ' 2 triangles
     GraphicsWindow.BrushColor="crimson"
      tri[1] =  Shapes.Addtriangle(350,350,418,200,420,350)
      Shapes.Move(tri[1], 0,0)
      tri[2] =  Shapes.Addtriangle(310,390,350,350,350,390,)
      Shapes.Move(tri[2], 0,0)

        GraphicsWindow.BrushColor="darkred"
       tri[3] =  Shapes.Addtriangle(585,405,585,420,450,390)
       Shapes.Move(tri[3], 0,0)

         GraphicsWindow.BrushColor="darkblue"
       tri[4] =  Shapes.Addtriangle(350,445,230,445,350,385)
       Shapes.Move(tri[4], 0,0)

      ' piston cylinder
        GraphicsWindow.BrushColor="darkred"
       rec[12] =  Shapes.Addrectangle(150,20)
       Shapes.Move(rec[12], 585,405)

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

     Sub OnKeyDown
      key= GraphicsWindow.LastKey
      BC=graphicswindow.GetRandomColor()
      GraphicsWindow.brushcolor=BC
      ball = Shapes.Addtriangle(50,50,80,20,110,50)
      Shapes.Move(ball,577, 700)
        If key = "B" then
               Shapes.animate(ball, 600, -100,3000)   
       EndIf
       key=""
     EndSub

                 with love from mussa-maina---------------mahreen miangul

                   
    Thursday, February 16, 2017 4:50 PM
  • Hi !

    my update was for to add some shapes , 2 big wheels and piston.

    version: ZWZ092-0

    and then NaochanON add this version to correct this:

    rec[9] is the top shape.

    el1y=shapes.GetTop(rec[9]) '

    version: ZWZ092-1

    so use the last version: ZWZ092-1

    Thursday, February 16, 2017 5:38 PM
    Answerer
  • You can only have one subroutine for KeyDown. In this sub, test for S W A P and B to execute the right part.

    You have no detection if the triangle is in the region of the train.


    Jan [ WhTurner ] The Netherlands



    Thursday, February 16, 2017 6:08 PM
    Answerer
  • mussa-maina    how about this. 

    If "B" press ball  moves to top, if ball hits tri[4](front of train), train stops.

    ball added  when ball  frame out.

      

    ZWZ092-3  '<----* continuously works.



    • Edited by NaochanONEditor Friday, February 17, 2017 3:13 AM
    • Marked as answer by mussamaina Friday, February 17, 2017 11:15 AM
    Friday, February 17, 2017 3:08 AM
    Answerer
  • version :  ZWZ092-4

    Hello !
    Here I wanted to change the colors of the train in order to reproduce the colors black, gray, red photo of the train found on Wikipedia.

    It's a try! :)

    Friday, February 17, 2017 4:47 PM
    Answerer
  • hello everybody Alphabetical Face ID QWR127 the ears are not comming very nice

    with love from mussa-maina

    Tuesday, February 21, 2017 11:47 AM
  •  program S-W-A-T ID GDC622 keys S-W-A-T are moving the sprite left right keys S-W should move the sprite left right and the sprite should be moved up down by keys A-T any help will be grate with thanks

        mahreen miangul                                                                mussa-maina

    Wednesday, February 22, 2017 11:32 AM
  • mussamaina,

    You should not ask the same question in two topics, that is confusing.

    In one of the previous topics about this progran I showed you how to add the key "B" to the program. You should do the same for the keys S W A T with for each key a different action ( left/right/up/down. )

    YOU can do it !!


    Jan [ WhTurner ] The Netherlands


    • Edited by WhTurner33Editor Wednesday, February 22, 2017 12:06 PM
    • Proposed as answer by YLedEditor Wednesday, February 22, 2017 10:27 PM
    Wednesday, February 22, 2017 12:05 PM
    Answerer
  • hello with regards the problem is i dont no 20% of  progrmming like you or i wold not have been on msb forum as a learner instead i would have been teaching programming through the net and would have been been a good teacher
    nice and simple tutorials only are needed  with thanks and best wishes       mahreen miangul
    13 hours 17 minutes ago