haihongyuan.com

# 网页制作实验性报告

Window7环境，C#软件环境

if (TheBall.Position.Y > this.ClientRectangle.Bottom - TheBall.YStep) // lost the ball!

{

IncrementGameBalls();

Reset();

}

if (RowsCollide(TheBall.Position))

{

TheBall.YStep *= -1;

}

if (hp > -1)// lost the ball!

{

switch (hp)

{

case 1:

TheBall.XStep = -7;

TheBall.YStep = -3;

break;

case 2:

TheBall.XStep = -5;

TheBall.YStep = -5;

break;

case 3:

TheBall.XStep = 5; if (TheBall.Postion.Y < 0) // hit the top of the form, switch polarity

{

TheBall.YStep *= -1;

TheBall.Position.Y += TheBall.YStep;

}

if (TheBall.Position.X > this.ClientRecta

ngle.Right - TheBall.Width ) // hit the left side, switch polarity

{

TheBall.XStep *= -1;

TheBall.Position.X += TheBall.XStep;

}

TheBall.YStep = -5;

break;

default:

TheBall.XStep = 7;

TheBall.YStep = -3;

break;

}

}

}

{

if (p.Y >= this.ClientRectangle.Bottom - (PaddleRect.Height + TheBall.Height) ) {

{

return 1;

return 2;

return 3;

else

return 4;

}

}

return -1;

}

private void IncrementGameBalls()

{

NumBalls++;

if (NumBalls >= kNumberOfTries)

{

timer1.Stop();

string msg = "Game Over\nYou knocked out " + NumTotalBricks; if (NumTotalBricks == 1)

msg += " brick.";

else

msg += " bricks.";

MessageBox.Show(msg);

Application.Exit();

}

}

private void Reset()

{

TheBall.XStep = 5;

TheBall.YStep = 5;

TheBall.Position.Y = this.ClientRectangle.Bottom - 190;

TheBall.Position.X = 5;

timer1.Stop();

TheBall.UpdateBounds();

}