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

Posts I've Made

In Topic: default xna 4.0 gametime don´t works well for physics

17 September 2012 - 03:06 PM

Problem "solved" the pixel amount difference between computers is because i have a fixedtimestep disabled and one of the tested computers monitor refresh rate is 75hz
If the monitor run at 75hz, in xna with isfixedtimestep=false and vsync actived the game run update 75 times per second.
When the two and more tested pcs are configured at 60hz in all of them works well and at same movement velocity.

In Topic: 2D Platformer fps/Independent- time based movement

16 September 2012 - 09:25 AM

Note, the GameTime object stores the elapsed and total time as a TimeSpan:
TimeSpan object store the units broken up in integer values:
So the seconds property is a WHOLE number. It represents the current seconds as a part of the timespan. So a Timespan representing 2 mins, 30 secs, 123 milliseconds, would return 30 for seconds from the Seconds property... not 150.123.
If you want ALL the seconds as a fracitonal value you access the TimeSpan.TotalSeconds property, which is a double. There are also TotalMilliseconds, Minutes, Hours, and Days...
So the TotalSeconds property on the other hand would return 150.123 for the previously mentioned TimeSpan.

In Topic: 2D Platformer fps/Independent- time based movement

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.