Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Aug 2012
Offline Last Active Sep 23 2012 08:17 AM

#4968738 2D Platformer fps/Independent- time based movement

Posted by on 12 August 2012 - 09:57 AM

ApplyPhysics () is executed in each Update() of Player.cs class which in turn runs on each Update() of Level.cs which in turn runs on each Update () of Game1.cs.
Yes, ApplyPhysics () is executed for every frame of the game.

movement keeps the direction in which the character moves (later is multiplied by moveAcceleration) -1 (left), 0 (not moving), 1 (right).
moveAcceleration keeps the acceleration, which later is multiplied by the number of seconds since the last frame.

[source lang="csharp"] /// <summary> /// Current user movement input. /// </summary> private float movement; public float Movement { set { movement = value; } } // For controling horizontal movement private float MoveAcceleration = 15000.0f; public float Move_Acceleration { get { return MoveAcceleration; } }[/source]

You can download the two classes (Player, Enemy) from the link I put in the post (Attached Files) to see all the code.