Page 1 of 1

Drawing a rectangle

PostPosted: Thu Jul 09, 2009 1:28 am
by Hblade
Hey I need some help on this part, ok, I have a canvas, right?? and like, when you click the canvas, it sets the xmous and ymouse to variables, so that the start of the box starts at where you clicked, but... I cant seem to get it to drag into square, here take this sample
wtf.zip
(1.27 KiB) Downloaded 85 times

Re: Drawing a rectangle

PostPosted: Thu Jul 09, 2009 2:04 am
by skydereign
This should work, you were mixing up your corners. Your first lineto was the set position, so it skipped a line, hence the triangle.
Code: Select all
if (d == 1)
{
    erase(0, 0, 0, 1);
    currentposx = xmouse;
    currentposy = ymouse;
    lineto(startposx,ymouse);
    lineto(xmouse, ymouse);
    lineto(xmouse, startposy);
    lineto(startposx, startposy);
}


Sorry I can't post the ged right now, don't know why, but that is the draw code....

Re: Drawing a rectangle

PostPosted: Thu Jul 09, 2009 2:23 am
by Hblade
O... Omg! your a genious!

Re: Drawing a rectangle

PostPosted: Thu Jul 09, 2009 2:53 am
by Hblade
Now I have another problem, when you let go of the mouse button, it DOES stop drawing the box yes, but when you click it again the box moves to a weird ass position.. try it yourself :/ then the box never goes away :O, it keeps following you it's odd

Re: Drawing a rectangle

PostPosted: Thu Jul 09, 2009 5:29 am
by skydereign
That doesn't happen to me, but here is a fix to do what you want, I think.

MouseButtonUp(left)
Code: Select all
d=0;


MouseButtonDown(left)
Code: Select all
erase(0, 0, 0, 1);
d = 1;
screen_to_actor(&xmouse, &ymouse);
moveto(xmouse, ymouse);

lineto(xmouse, ymouse);
startposx = xmouse;
startposy = ymouse;

Re: Drawing a rectangle

PostPosted: Thu Jul 09, 2009 12:09 pm
by Hblade
I put that,m but it still dosnt re-create another box, here look
wtf.zip
(1.34 KiB) Downloaded 79 times

Re: Drawing a rectangle

PostPosted: Thu Jul 09, 2009 9:52 pm
by skydereign
Is this what you want?

Re: Drawing a rectangle

PostPosted: Thu Jul 09, 2009 11:55 pm
by Hblade
Thanks :D