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.

DarkBASIC Discussion / Drawing lines with dots?

Author
Message
t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 27th Jul 2009 05:02
If you had two points could you(useing dots)make a line?

WHY?

So you can make somthing follow you.

If their is a better way please tell but I would like to know how to do the above.

I know you can>


but that makes it follow this path>


And I want it to look like this>


Thanks in advance because I might not be able to respond until 5 days from now.


Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Jul 2009 05:10
So do you want to draw a line from A to B, or make an object move from A to B?

In response to the first, look up bresenham's algorithm, I even have an implementation of it: http://forum.thegamecreators.com/?m=forum_view&t=82515&b=1

As for the latter, use atanful() to get the angle between the two points then increment an objects position this way:

angle = atanful(bx-ax, by-ay)
X = X + cos(angle)*step
Y = Y + sin(angle)*step

Where 'step' is how much you want to increment the position by.

[url="http://dbcc.zimnox.com"][/url]
t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 27th Jul 2009 05:31
Thanks Phaelax, I Did'nt expect such a great answer so fast.

That was exactly what I was looking for.


That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 27th Jul 2009 05:49 Edited at: 27th Jul 2009 05:55
I asked the same question a few months ago, heres the link:

http://forum.thegamecreators.com/?m=forum_view&t=151085&b=10

not sure if the function is in there, ill see if I can find it

edit:

heres the 2 functions i used to make it:



Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Aug 2009 06:57
Look at my memblock functions in OBese87's Code Bonanza even if you don't understand memblocks you can see how this works.

I notice TGC have started using the word "bonanza", always copying me...

TGC Forum - converting error messages into sarcasm since 2002.
t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 9th Aug 2009 07:15
lol,I've already got your "bonanza" in my profiles.There great help.

Thanks though.


That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 10th Aug 2009 00:35
did u read my thread razer?

I think those functions I posted will accomplish exactly what you're looking for, if you need to understand anything then just ask

also read through the thread about my gradient line function, turned out pretty cool

t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 10th Aug 2009 04:41
Ya, I got that thanks.(sorry for not saying anything earlyer).


Login to post a reply

Server time is: 2024-05-20 06:40:05
Your offset time is: 2024-05-20 06:40:05