J
joshMohamed
Guest
I'm trying to make an object to follow my mouse I think I'm doing good but I have a little problem
public void main()
{
try
{
// main loop ,drawing from first point to the mouse
rX = MousePosition.X; rY = MousePosition.Y;
Graphics graphicsObj;
graphicsObj = this.CreateGraphics();
Pen myPen = new Pen(Color.BlueViolet, 3);
Point point = new Point(mX, mY);
Rectangle myRectangle = new Rectangle(X, Convert.ToInt16(Y), 50, 50);
graphicsObj.Clear(Color.White);
mX = myRectangle.X;
mY = myRectangle.Y;
Y = (X - mX) * ((mY - rY) / (mX - rX)) + mY;
graphicsObj.DrawEllipse(myPen, myRectangle);
//myRectangle.Location = new Point(X, (X - mX) * ((mY - rY) / (mX - rX)) + mY);
label1.Text = "( " + X + " , " + Y + " )" + "( " + rX + " , " + rY + " )";
}
catch
{
}
finally
{
}
}
when I tried to find out why the ellipse didn't move in Y-axis I found that Y always zero, can anyone tell me why its equal zero, I have tried the equation many times in paper and it is true but I don't know why it is zero
Continue reading...
public void main()
{
try
{
// main loop ,drawing from first point to the mouse
rX = MousePosition.X; rY = MousePosition.Y;
Graphics graphicsObj;
graphicsObj = this.CreateGraphics();
Pen myPen = new Pen(Color.BlueViolet, 3);
Point point = new Point(mX, mY);
Rectangle myRectangle = new Rectangle(X, Convert.ToInt16(Y), 50, 50);
graphicsObj.Clear(Color.White);
mX = myRectangle.X;
mY = myRectangle.Y;
Y = (X - mX) * ((mY - rY) / (mX - rX)) + mY;
graphicsObj.DrawEllipse(myPen, myRectangle);
//myRectangle.Location = new Point(X, (X - mX) * ((mY - rY) / (mX - rX)) + mY);
label1.Text = "( " + X + " , " + Y + " )" + "( " + rX + " , " + rY + " )";
}
catch
{
}
finally
{
}
}
when I tried to find out why the ellipse didn't move in Y-axis I found that Y always zero, can anyone tell me why its equal zero, I have tried the equation many times in paper and it is true but I don't know why it is zero
Continue reading...