private void CheckPad(MyPad pad, MyBall ball) { if (pad.CheckInter(ball)) { ball.velo.Y = -2; } }
private void CheckRightWall(MyBall ball) { if (ball.pos.X >= stageWidth) { ball.velo.X = -2; } }
private void CheckTopWall(MyBall ball) { if (ball.pos.Y <= 0) { ball.velo.Y = 2; } }
private void CheckLeftWall(MyBall ball) { if (ball.pos.X <= 0) { ball.velo.X = 2; } }
private void CheckBottom(MyBall ball) { if (ball.pos.Y > pad.pos.Y + 10) { gameEnd = true; MessageBox.Show("game end"); } }
private void CheckBlocks(MyBall ball) { for (int j = 0; j < 2; j++) { for (int i = 0; i < 5; i++) { blocks[i, j].Check(ball); } } }
public void Check(MyBall ball) { if (hide) { return; } if (this.CheckInter(ball)) { hide = true; ball.velo.X = -ball.velo.X; ball.velo.Y = -ball.velo.Y; } }
private void Form1_Load(object sender, EventArgs e) { pad = new MyPad(); ball = new MyBall(); blocks = new MyBlock[5, 2]; for (int j = 0; j < 2; j++) { for (int i = 0; i < 5; i++) { blocks[i, j] = new MyBlock(); } } this.ResetPosition(); timer1.Start(); }