I'm doing basic tests on Monogame using Monodevelop as IDE. What I have is a rectangle moving random and always diagonally bouncing against the window boundaries (I'm running the game in window mode). I'm setting a velocity vector but as soon a I set velocity above 60 frames per second the rectangle leaves a noticeable trail. My Motion method is as follows:
public void Move(int elapsedMiliseconds)
{
this.delta+= elapsedMiliseconds;
//Remember, I express speed in px/s so I must divide by 1000
float X = (delta*this.Velocity.X/1000f);
float Y = (delta*this.Velocity.Y/1000f);
//Verify that the increment is at least 1px since there's
//no such a thing like a half pixel
//I dont't bother checking 'Y' since Vx and Vy are always equal
if(X >= 1f)
{
//This prevent jerky motion when frames drop down
//in exchange the movement get slow but at least not jerky
float maxStepX = this.Velocity.X/60f;
float maxStepY = this.Velocity.Y/60f;
X=MathHelper.Clamp(X,0f,maxStepX);
Y=MathHelper.Clamp(Y,0f,maxStepY);
//Set new location for the rectangle
square.X+= (int)(this.DirectionX*X);
square.Y+= (int)(this.DirectionY*Y);
this.delta=0;
}else{
this.delta+=this.delta;
}
}
As I've said, as soon as I get a maxStepX/maxStepY above 2 pixels y get a trail like a faded shadow in the previous position of the square. I'm wondering if it's just a natural visual effect and i have to bear with it or there's something I can do to get rid of that trail. Any hints?
My Draw method is this:
protected override void Draw (GameTime gameTime)
{
graphics.GraphicsDevice.Clear (Color.Violet);
spriteBatch.Begin ();
spriteBatch.Draw(Texture,square,Color.Orange);
spriteBatch.End ();
base.Draw (gameTime);
}
If I do a snapshot I just see the screen and the rectangle totally clear (no trail). I've recorded my desktop and it seems that my computer can't handle both the game and the recorder and the output is quite lagged but I can see the trail there and if I play it at slow motion I just see no trail, just the rectangle jumping from one position to another.
EDIT: Ok I got some progress here. Until now I've been using a white pixel as texture to draw rectangles with plain colours but if I use a soccer ball with transparent background as texture there's no trail but it gets blurrier and blurrier as I increase the speed.