I have an object that can move in any direction(user define) but as you can see, it doesn't move smoothly.
how can I improve this movement.
here is a video of this object movement.
bandicam 2022-06-12 10-43-26-451.mp4 - Google Drive[
^]
private void timer2_Tick_1(object sender, EventArgs e)
{
float xpos,yapos,yspos,dif;
double atheta;
if (aireplane1.Top >= brec.Top + 10)
if (startmove && !airisdragging)
{
Size aireplane_size =aireplane1.Size;
if (keynum>0 && keynum<180) {
atheta = Math.Atan2(aireplane1.Location.Y , aireplane1.Location.X);
atheta = atheta *180 / Math.PI;
yspos = -(float)Math.Tan(Math.PI/2- keynum * (Math.PI / 180)) * aireplane1.Location.X;
dif = yspos-aireplane1.Location.Y;
xpos =( aireplane1.Location.X)+2;
yspos = -(float)Math.Tan(Math.PI / 2-keynum * (Math.PI / 180)) * xpos;
yapos = yspos - dif;
aireplane1.SetBounds((int)xpos,(int)(yapos),aireplane_size.Width,aireplane_size.Height);
}
else if (keynum >180 && keynum < 360)
{
atheta = Math.Atan2(aireplane1.Location.Y, aireplane1.Location.X);
atheta = atheta * 180 / Math.PI;
yspos = -(float)Math.Tan(Math.PI / 2 - keynum * (Math.PI / 180)) * aireplane1.Location.X;
dif = yspos - aireplane1.Location.Y;
xpos = (aireplane1.Location.X) - 2;
yspos = -(float)Math.Tan(Math.PI / 2 - keynum * (Math.PI / 180)) * xpos;
yapos = yspos - dif;
aireplane1.SetBounds((int)xpos, (int)(yapos), aireplane_size.Width, aireplane_size.Height);
}
}
}
keeynum is user angle input.
by changing time intervals the movement become smoother but still the background of the path of airplane change when it across it, how can I fix this?
bandicam 2022-06-13 17-18-00-689.mp4 - Google Drive[
^]
What I have tried:
I didn't do anything more than this