private void Form1_MouseClick(object sender, MouseEventArgs e) { world.AddObject(new Models.GravityObject { Position = new Models.Vector2(mousePosition.X, mousePosition.Y), Mass = launchObject.Mass, Radius = launchObject.Radius, Velocity = new Models.Vector2(launchSpeed, 0) }); }
public Form1() { InitializeComponent(); updateTimer = new Timer(); updateTimer.Interval = 10; world = new WorldController(); var speed = 4f; /*world.AddObject(new Models.GravityObject * { * Position = new Models.Vector2(200, 200), * Mass = 50, * Radius = 50, * Velocity = new Models.Vector2(speed, 0) * }); * * world.AddObject(new Models.GravityObject * { * Position = new Models.Vector2(400, 200), * Mass = 50, * Radius = 50, * Velocity = new Models.Vector2(speed, 0) * });*/ world.AddObject(new Models.GravityObject { Position = new Models.Vector2(300, 300), Mass = 500, Radius = 50, Velocity = new Models.Vector2(0, 0) }); /*world.AddObject(new Models.GravityObject * { * Position = new Models.Vector2(200, 400), * Mass = 50, * Radius = 50, * Velocity = new Models.Vector2(-speed, 0) * }); * * world.AddObject(new Models.GravityObject * { * Position = new Models.Vector2(400, 400), * Mass = 50, * Radius = 50, * Velocity = new Models.Vector2(-speed, 0) * });*/ DoubleBuffered = true; launchObject = new GravityObject { Mass = 50, Radius = 50, Velocity = new Vector2(), Position = new Vector2() }; Paint += Form1_Paint; KeyDown += Form1_KeyDown; MouseClick += Form1_MouseClick; MouseWheel += Form1_MouseWheel; MouseMove += Form1_MouseMove; updateTimer.Tick += UpdateTimer_Tick; updateTimer.Start(); }