float a = 0.005f;
float v0 = 0.001f;
float deltaT;
float v=0.1f;
Stopwatch MyStopWatch;
public void StartGoingDown(Panel MyPanel, Form MyForm)
{
MyStopWatch = new Stopwatch();
MyStopWatch.Start();
System.Threading.Thread.Sleep(20);
//while (MyBall.Top < MyPanel.Height-90)
while(Math.Abs(v)>0 && Math.Abs(v0)>0)
{
deltaT = MyStopWatch.ElapsedMilliseconds;
v = v0 + a * deltaT/1000;
MyBall.Top += (int)(v * deltaT);
DrawBall();
if (MyBall.Top >= MyPanel.Height - 90)
{
MyBall.Top = MyPanel.Height - 91;
MyStopWatch.Reset();
MyStopWatch.Start();
v0 = -v;
v = 0;
//MyBall.Top -= 100;
}
System.Threading.Thread.Sleep(20);
}
DrawBall();
}
No replies to this topic
#1
Posted 14 September 2010 - 01:23 PM
I know that using panels isn't a good way for animantion. Please, tell me. I'm try to code a physical model for ball (Panel). But it doesn't work.
|
|
|
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









