2
このゲームはまだ完成していませんが、ボールがボードに当たる部分を作成しましたが、プレーに問題があり、ボールがボードにこびりついています。より良い理解とunderstaningのために、私は下に画像を添付しました、それを見て、このバグをあなたのテイクを知っている。ボードにボールを詰め込んだ(ピンポンゲーム)
public partial class PingPong : Form
{
public PingPong()
{
InitializeComponent();
timer1.Enabled = true;
timer1.Interval = 30;
}
int mx = 5;
int my = 5;
private void timer1_Tick(object sender, EventArgs e)
{
if (ball.Bounds.IntersectsWith(boardCenter.Bounds))
{
mx = mx * -1;
my = my * 1;
}
else if (ball.Location.Y >= this.ClientSize.Height - ball.Height)
{
mx = mx * 1;
my = my * -1;
}
else if (ball.Location.Y <= 0)
{
mx = mx * 1;
my = my * -1;
}
else if (ball.Location.X >= this.ClientSize.Width - ball.Width)
{
mx = mx * -1;
my = my * 1;
}
ball.Location = new Point(ball.Location.X + mx, ball.Location.Y + my);
}
private void PingPong_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Up)
{
board.Location = new Point(board.Location.X, board.Location.Y - 4);
}
else if (e.KeyCode == Keys.Down)
{
board.Location = new Point(board.Location.X, board.Location.Y + 4);
}
}
}
わかりやすく理解していただくために、私はビデオを入れました。https://youtu.be/WSZxw42qR-E –