Drawing a rectangle

Non-platform specific questions.

Drawing a rectangle

Postby Hblade » Thu Jul 09, 2009 1:28 am

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 86 times
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Drawing a rectangle

Postby skydereign » Thu Jul 09, 2009 2:04 am

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....
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Drawing a rectangle

Postby Hblade » Thu Jul 09, 2009 2:23 am

O... Omg! your a genious!
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Drawing a rectangle

Postby Hblade » Thu Jul 09, 2009 2:53 am

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Drawing a rectangle

Postby skydereign » Thu Jul 09, 2009 5:29 am

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;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Drawing a rectangle

Postby Hblade » Thu Jul 09, 2009 12:09 pm

I put that,m but it still dosnt re-create another box, here look
wtf.zip
(1.34 KiB) Downloaded 80 times
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Drawing a rectangle

Postby skydereign » Thu Jul 09, 2009 9:52 pm

Is this what you want?
Attachments
wtf.zip
(1.39 KiB) Downloaded 76 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Drawing a rectangle

Postby Hblade » Thu Jul 09, 2009 11:55 pm

Thanks :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron