locked
Small Basic Movement RRS feed

  • Question

  • How can you make something move ONLY when the key is down. So far, this is what i came up with, but he doesnt stop moving when i release the button. Is there anything i can do to make him move only when the button is down?

    Please help (:

    Begin:
    y = 260
    GraphicsWindow.Clear()
    GraphicsWindow.BrushColor = "Green"
    GraphicsWindow.FillRectangle(0,400,700,100)


    If (x > m1x or x < m1x + 50) Then
      m1x = Math.GetRandomNumber(600)
      m1y = Math.GetRandomNumber(400)
    EndIf

     

    GraphicsWindow.BackgroundColor = "Navy" 'Navy

    'Coordinates of torso are(30,60)

    GraphicsWindow.BrushColor = "Tan"
    GraphicsWindow.FillRectangle(x + 10,y - 20,20,20)'Head
    GraphicsWindow.BrushColor = "Blue"
    GraphicsWindow.FillRectangle(x,y,40,60)'Torso x+0 y+0
    GraphicsWindow.FillRectangle(x + 10,y - 30,20,10)''bottom of hat
    GraphicsWindow.FillRectangle(x + 15,y - 35,10,10)'Top of hat
    GraphicsWindow.FillRectangle(x + 30,y - 25,20,5)'Visor of hat
    GraphicsWindow.BrushColor = "Black"
    GraphicsWindow.FillRectangle(x,y + 60,15,80)'Our left leg
    GraphicsWindow.FillRectangle(x + 25,y + 60,15,80)'Our right leg
    GraphicsWindow.FillRectangle(x + 40,y + 120,10,20)'Our right foot
    GraphicsWindow.FillRectangle(x - 10,y + 120,25,20)'Our left foot

    'These are his moving controls
    If (GraphicsWindow.LastKey = "Right") Then
      x = x + 10
    EndIf

    If (GraphicsWindow.LastKey = "Left") Then
      x = x - 10
    EndIf

    'These make the screen wrap around
    If (x = 700 Or x > 700)Then
      x = -45
    EndIf

    If (x < -50) Then
      x = 690
    Endif 

     

     

    Program.Delay(50)


    Goto Begin

    Sunday, December 5, 2010 4:19 AM

Answers

  • I don't know what system you are using, but this question is not about Robotics Developer Studio.

    Trevor

     

    Friday, December 10, 2010 8:19 AM