0

マウスに追従する を作成しようとしてButtonいますが、ボタンが無限大になります。

private void Form1_Load(object sender, EventArgs e)
{
    Random r = new Random();
    Xstart = r.Next(100);
    Ystart = r.Next(100);
}

private void timer1_Tick(object sender, EventArgs e)
{
    if (X != Xstart)
    {
        int m = ((Y - Ystart)) / (X - Xstart);
        Xadd = constant * Math.Sign(X - Xstart);
        Yadd = Convert.ToInt16(m * constant * Math.Sign(Y - Ystart));
        Xdegisken = Xstart + Xadd;
        Ydegisken = Ystart + Yadd;
        button1.Location = new Point(Xdegisken, Ydegisken);
        this.Text = "(" + m + " , " + Yadd + " , " + L + "," + alfa + ")";
        Xstart = Xdegisken;
        Ystart = Ydegisken;
    }
}
4

0 に答える 0