有小BUG的。
涉及动量守和定律,和能量守恒定律。
碰撞的时候,有粘连重叠问题。求大神纠正!小弟,找了好久都没找到!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace Cool_Graphics01
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
Thread t = new Thread(new ThreadStart(CrossThreedFlush));
t.IsBackground = true;
t.Start();
}
private delegate void DelegateGDIMove(Circle[] cs);
//线程占用主控制权,还没有与主线程发生异步
private void CrossThreedFlush()
{
Color[] color = { Color.Red, Color.Blue, Color.Green, Color.DarkOrange, Color.Black, Color.DeepPink, Color.Purple, Color.Yellow };
Circle[] cs = new Circle[3];
/* for (int i = 0; i < 7; i++)
{
cs[i] = new Circle();
cs[i].Center = new PointF(50*i+50, 50*i+50);
cs[i].Radius = 25;
cs[i].MoveSpeed = 3.0f;
cs[i].Weight = 15;
cs[i].Direct = 1.2 * i + 0.2;
cs[i].CircleColor = color[i];
}
*/
cs[0] = new Circle();
cs[0].Center = new PointF(100, 50);
cs[0].Radius = 20;
cs[0].MoveSpeed = 3.0f;
cs[0].Weight = cs[0].Radius*cs[0].Radius*cs[0].Radius;
cs[0].Direct = 0;
cs[0].CircleColor = Color.Red;
cs[1] = new Circle();
cs[1].Center = new PointF(50, 50);
cs[1].Radius = 25;
cs[1].MoveSpeed = 3.0f;
cs[1].Weight = cs[1].Radius*cs[1].Radius*cs[1].Radius;
cs[1].Direct = Math.PI * 0.25;
cs[1].CircleColor = Color.Green;
cs[2] = new Circle();
cs[2].Center = new PointF(50, 120);
cs[2].Radius = 30;
cs[2].MoveSpeed = 3.0f;
cs[2].Weight = cs[2].Radius * cs[2].Radius * cs[2].Radius;
cs[2].Direct = Math.PI*0.5;
cs[2].CircleColor = Color.Blue;
/*
cs[3] = new Circle();
cs[3].Center = new PointF(200, 150);
cs[3].Radius = 32;
cs[3].MoveSpeed = 3.0f;
cs[3