The fact is that I could use the method of physics that brings the starter kit, (thought they were independent of fps) but to start porting the game to linux by monoGame and lowered fps (windows 63, Ubuntu / Kubuntu 57-59) I then checked that the player did not move properly.
The funny part is that the enemies are moving properly, it have only movement in the x axis.
Now being tested in windows disabling Vertical Sync by:
[source lang="csharp"] graphics.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = false;[/source]
I leave the pieces of code relevant to them a look.
I believe that these method would be involved:
ApplyPhysics
[source lang="csharp"] public void ApplyPhysics(GameTime gameTime) { float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; Vector2 previousPosition = Position; // Base velocity is a combination of horizontal movement control and // acceleration downward due to gravity. velocity.X += movement * MoveAcceleration * elapsed; velocity.Y = MathHelper.Clamp(velocity.Y + GravityAcceleration * elapsed, -MaxFallSpeed, MaxFallSpeed); velocity.Y = DoJump(velocity.Y, gameTime); // Apply pseudo-drag horizontally. if (IsOnGround) velocity.X *= GroundDragFactor; else velocity.X *= GroundDragFactor; //velocity.X *= AirDragFactor; // Prevent the player from running faster than his top speed. velocity.X = MathHelper.Clamp(velocity.X, -MaxMoveSpeed, MaxMoveSpeed); // Apply velocity. Position += velocity *elapsed; Position = new Vector2((float)Math.Round(Position.X), (float)Math.Round(Position.Y)); // If the player is now colliding with the level, separate them. HandleCollisions(gameTime); // If the collision stopped us from moving, reset the velocity to zero. if (Position.X == previousPosition.X) velocity.X = 0; if (Position.Y == previousPosition.Y) { velocity.Y = 0; jumpTime = 0.0f; } }[/source]
I'm trying to simplify character movement putting it as the enemy,
[source lang="csharp"] Vector2 velocity = new Vector2((int)direction * MoveSpeed * elapsed, 0.0f); position = position + velocity;[/source]
but then come the problems of collisions of the character in both axes (X, Y) ...
Attached to the post player and enemy classes of my project.
I would appreciate a little help from someone who is put in the subject, thanks in advance for your time and sorry for my bad English ;).
Attached Files
Edited by EusKoder, 08 August 2012 - 04:00 AM.







