c#物理引擎,抛物线,

  • Post author:
  • Post category:其他


private void frmPhisical_Load(object sender, EventArgs e)

{

Bitmap bitmap = new Bitmap(100, 100);

Graphics gra = Graphics.FromImage(bitmap);

Brush bru = new SolidBrush(Color.Green);

new Thread(() =>

{


double x = 0;//开始位置

double y = 90;

double addx = 1;//开始速度

double addy = -3;//开始速度

double addx2 = 0;//加速度x

double addy2 = 0.1;//加速度y

while (true)

{


addx += addx2;

addy += addy2;

if (x >= 0 && x <= 90)

{


x += addx;

}

if (y >= 0 && y <= 90)

{


y += addy;

}

//gra.Clear(Color.White);

gra.FillRectangle(bru, (float)x, (float)y, 1, 1);

System.Threading.Thread.Sleep(30);

try

{


this.Invoke(new Action(() =>

{


pbPyhsical.Image = bitmap;

}));

}

catch (Exception)

{


return;

}

}

}).Start();

}



版权声明:本文为qq_32066515原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。