locked
effect of gravity RRS feed

  • Question

  • Good evening,

    I would try to play a little game with a character that bounces.
    The principle would be to bounce the character for him to go on the small platform on a 1024x576 screen.
    Is there an equation that can move the character in a half sine wave, with gravity? and how to perform a detection of this character on the platform?

    Thank you.

    absolu
    Saturday, December 10, 2011 9:35 PM

Answers

  • You need to store the coordinates of the image centre and apply the movement to these.  There are plenty of examples of SB using gravity, but each game is different and there are no general formula.  You need to think carefully what movement you want and how to calculate the position at all times and any collisions.

    Start with simple code to test what you want  the image to do - perhaps just a rectangle shape and the basics of the movement and user controls.

    To give an equation for 'move the character in a half sine wave, with gravity' you need to exactly state what you want it to do.

    box = Shapes.AddRectangle(20,50)
    GraphicsWindow.DrawLine(0,400,GraphicsWindow.Width,400)
    
    For i = 1 To 500
      x = 50+i'Move right
      y = 400-25-100*Math.Abs(Math.Sin(i/50))
      Shapes.Move(box,x-10,y-25)
      Program.Delay(20)
    EndFor


    Saturday, December 10, 2011 10:44 PM