Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Clbembry
19
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 12th Mar 2011 21:23
Does anyone know of an efficient way to make lines with thickness?

C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 12th Mar 2011 21:34
Off the top of my head a good way might be to paste a rotated sprite at the centre of the projected line and scale it accordingly. - Then round the ends off with some circle pasted sprites or something (unless you still wanted a rectangular line)

Clbembry
19
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 12th Mar 2011 21:42
Ah, I see. How would I make a sprite from lines drawn to the screen?

C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 12th Mar 2011 21:55
Well it's just a case of some basic trigonometry I believe.

Lets say you were trying to make a line from x1,y1 to x2,y2:


In sprite terms you'd need something like this:


But of course it would need offset to get the exact location correct and some rounder ends. - And you could change the texture pixel of the line as well to add affects to it if you didn't want it single colour.

Clbembry
19
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 12th Mar 2011 22:09
The problem is I need the user to be able to draw the lines, so I was using:



And no, I'm not trying to make a full out drawing program

C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 12th Mar 2011 22:14
Regardless of whether the user is drawing them you can still use the same method. - Just paste the sprite accordingly as many times as the user draws a line.

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 12th Mar 2011 22:37 Edited at: 12th Mar 2011 22:43
Code snippets/Phalaex!
thick lines:
http://forum.thegamecreators.com/?m=forum_view&t=137834&b=6

anti-aliased lines/circles:
http://forum.thegamecreators.com/?m=forum_view&t=161349&b=6

There are also probably a lot of drawing snippets on his website:
http://zimnox.com/
[edit]
yup

Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 12th Mar 2011 22:42
Here's a version that just draws multiple lines. If you want to be able to adjust the thickness, then one of the above links should do it.



Clbembry
19
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 12th Mar 2011 22:45
The problem with Phalaex's example is its not actually drawing lines, so if the user moves their cursor fast enough there are gaps between the boxes.

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 12th Mar 2011 22:50
Quote: "The problem with Phalaex's example is its not actually drawing lines, so if the user moves their cursor fast enough there are gaps between the boxes."

huh? it has nothing to do with the speed of the cursor... could you give me an example of there being gaps in between the boxes...?

Clbembry
19
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 12th Mar 2011 22:58
Here's Phalaex's code that I slightly changed so it allowed to user to free draw. Just run it and you'll see what I mean.



Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 13th Mar 2011 00:27
you did it wrong o.o


Clbembry
19
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 13th Mar 2011 00:49
Oh ,
Thanks

Login to post a reply

Server time is: 2026-07-14 22:23:06
Your offset time is: 2026-07-14 22:23:06