Code:
using System;
using System.Windows.Forms;
using System.Drawing;
namespace CsStudy
{
class Bounce:Form
{
const int iTimerInterval = 20;
const int iBallSize = 16;
const int iMoveSize = 5;
Bitmap bitmap;
int xCenter, yCenter;
int cxRadius, cyRadius, cxMove, cyMove, cxTotal, cyTotal;
static void Main()
{
Application.Run(new Bounce());
}
public Bounce()
{
Text = "弹球动画";
ResizeRedraw = true;
BackColor = Color.White;
Timer timer = new Timer();
timer.Interval = iTimerInterval;
timer.Tick+=new EventHandler(timer_Tick);
timer.Start();
OnResize(EventArgs.Empty);
}
protected override void OnResize(EventArgs e)
{
Graphics grph = CreateGraphics();
grph.Clear(BackColor);
float fRadius =