forums

TNT Basic Forums > Programming Q&A
First installment in Programmer's Toolkit
< Last Thread     Next Thread >
Author
Thread        Post A Reply

08-19-2005 08:21

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

I've just posted the first installment of the programmer's toolkit to the directory. This example shows a TNT implementation of Breshenam's Midpoint Line Algorithm, a handy tool for RTS and other 'point and click' engines. It moves an object quickly to a specified point by the shortest route, no floats, no complex math. It is fully working and heavily commented, and includes a speed modifier and handy direction finding mechanism.
There is no tutorial with this, it's pretty self explanatory, but any questions can be posted here.
I will be posting more source and tutorials over time which will build into a library of 'handy doohickeys' to get you out of a tight spot. All suggestions (legal and physically possible please!) are considered.
Watch this space!

Danny (nods)

08-19-2005 15:58

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

where abouts?

i cant see it in the directory

cheers
charlie

08-19-2005 22:11

Posted by:
Mark Tully

Location:
TNT HQ, England

Click Here to Email Mark Tully   Find more posts by Mark Tully

All submitted examples enter a holding area until I ok them - Danny's example has just gone online now.

Cheers,

Mark

11-20-2006 03:03

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

WOW, how long?

OK, it's been a while I know, but I've just finished a major PC job that has taken me a while (no Shit!)...

I'm now back in the TNT fold, and to celebrate this momentous occasion I've released an update of my (ever popular?) Bresenham code. I'm writing an RPG in TNT and I'm using my original sample (still lurking in the directory) as a base. This addition adds an animated character as the main object and addresses a few common issues with moving an animated sprite with the mouse. It does pretty much what you would expect, and does so pretty quickly on both G3 and Intel machines (YES! I'VE FINALLY GOT A MACTEL BOX! -another possible reason for the delayed absence- been playing), but not in hardware mode (surprise surprise...). Leave this with me though as I'm getting a bit cross with this and am back in XCode looking at options. My ramblings on this are well known so I'll not go too much further here, but look out for a pretty strong post fairly soon in the open source forum, I've got some radical ideas I'm working on, and yes, I AM WORKING ON THIS (the development team is still 2 people).

I've also had a play with my 3D code (also in directory) and have been working on putting the camera inside the cube (displaying a 3D room), but it's proving harder than expected due to TNT's limited data structure options. I'll get round it though... that's what programmers do, right?

Anyway, until the revised version of my point and click code shows up in the directory you can get a copy of the source by clicking here. Anyone who has seen any of my code before will know about my love of comments, but I strongly recommend that you read them, especially if you plan to use any of it. Any questions can be posted here, or mailed direct to me... I don't mind.

Well it's good to be back, and keep an eye out for a few well chosen posts coming your way fairly soon...

Danny (nods)

11-21-2006 22:02

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

very nice

11-25-2006 23:35

Posted by:
pseudoprometheus

Location:
Omaha, United States

Find more posts by pseudoprometheus

Sweet, thanks for updating this.

12-10-2006 04:31

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

This should be useful for my rts... thanks!

12-10-2006 20:55

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

You're welcome...

;)

Danny (nods)

01-06-2007 07:38

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Hey... couldn't sin+cos accomplish the same job? although it might be slower.

01-06-2007 12:20

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Think you're missing the point... ;)

Yeah, sin & cos is how you would normally do it... It's called the 'line equation'.

This version is a replacement for that, it removes the need for complex math and floating point, and simply increments and decrements integers, which is a lot faster. Any multiplication is done during set up and can be replaced by bit shifts to further boost the speed.

So to answer your question: Yes, sin & cos do the same thing, this bit of code just means they don't have to...

Danny (nods)

01-07-2007 05:41

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

...
what about this?
you have x1,y1 and x2,y2.
you can use pythagoras'theorem to measure its distance. you also have a speed you want to move the object. Now, simply use the internal ratio formula to keep working out the next coordinate the object should be on.

No complex maths such as 'sin and cos' but still multiplication and division.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.