Posted: Sat May 14, 2011 7:18 pm Post subject: RE:More efficient 360 degree movement + distance formula?
Then draw statements definitely.
Sponsor Sponsor
tyuo9980
Posted: Sat May 14, 2011 7:23 pm Post subject: Re: More efficient 360 degree movement + distance formula?
it sucks how u cant edit posts...
anyways i simplified the formula even further without using sqrt.
since it will only detect a collision when the distance is less than 30pixels, the distance of a to b will always be definitely be 29 or 30.
Raknarg
Posted: Sat May 14, 2011 7:27 pm Post subject: RE:More efficient 360 degree movement + distance formula?
Btw, you you there's a predefined function for the distance between two points?
Math.Distance (x1, y1, x2, y2)
Just so you know.
tyuo9980
Posted: Sat May 14, 2011 7:32 pm Post subject: Re: RE:More efficient 360 degree movement + distance formula?
Raknarg @ Sat May 14, 2011 7:27 pm wrote:
Btw, you you there's a predefined function for the distance between two points?
Math.Distance (x1, y1, x2, y2)
Just so you know.
yea you mentioned that b4, but i dont want to use sqrt since it can slow down the program by quite a bit.
Raknarg
Posted: Sat May 14, 2011 7:40 pm Post subject: RE:More efficient 360 degree movement + distance formula?
Lol, whoops, forgot about that.
Makes sense. So is the collision detection actual circle collosion? Like it changes angle accoding to its direction and where it hits?
tyuo9980
Posted: Sat May 14, 2011 8:03 pm Post subject: Re: RE:More efficient 360 degree movement + distance formula?
Raknarg @ Sat May 14, 2011 7:40 pm wrote:
Lol, whoops, forgot about that.
Makes sense. So is the collision detection actual circle collosion? Like it changes angle accoding to its direction and where it hits?
yep.
RandomLetters
Posted: Sat May 14, 2011 8:34 pm Post subject: RE:More efficient 360 degree movement + distance formula?
Usually, x*x is much faster than x^2. Although at this point I don't think the efficiency of your code is the problem.
tyuo9980
Posted: Sat May 14, 2011 10:40 pm Post subject: Re: RE:More efficient 360 degree movement + distance formula?
RandomLetters @ Sat May 14, 2011 8:34 pm wrote:
Usually, x*x is much faster than x^2. Although at this point I don't think the efficiency of your code is the problem.
so do you think that its just turing?
Sponsor Sponsor
DemonWasp
Posted: Sat May 14, 2011 10:41 pm Post subject: RE:More efficient 360 degree movement + distance formula?
Hmm. I'd missed the bonus that, since the speed of these things is 1, the worst-case scenario is that the distance between them is 28 (both going opposite directions, immediately after a collision). You could always just assume that the "closeness" factor I described is 1 (which you do), and it'll be close enough. Very nice.
You should probably also avoid recalculating dx and dy so many times -- you calculate them between 1 and 3 times in your most recent post (once for checking collision, once for calculating distance, and once for calculating the final dx and dy you use.
Aside from that, I think any slowness you're fighting is due to Turing being slow. You could look into using BSPs or other algorithmic improvements, but they're all pretty complex. Try to make do with the performance you have, and see where you can get with that.
tyuo9980
Posted: Sat May 14, 2011 11:12 pm Post subject: Re: More efficient 360 degree movement + distance formula?
thanks guys!
now this is only about 65% of the whole game. i still have to add 'bar' collision and dead/alive filters to the objects. i think the program will good up until ~90 - 100 on my computer after that's added.
the school computers... ehh no so much. i would expect ~40-50
anyways my teacher understands how slow turing can be so i dont think my mark will drop because of this. maybe next yr in gr11 ill b learning another language thats faster, probably pascal. i would really like to learn C++ or C#. only if the schools taught that....
mirhagk
Posted: Sun May 15, 2011 12:23 am Post subject: RE:More efficient 360 degree movement + distance formula?
Your school doesn't teach C++ or C#?
I am working on tutorials to upgrade from turing to C#, since it really isn't that difficult, it's still all high level, just now it actually is powerful.
The funny thing is that with something like C# you could use this with thousands and thousands of objects without ever hitting lag lol. Turing is REALLY slow, it actually compiles to C++ (I've been told), so it probably compiles to an old version, with outdated libraries. If I ever take a course on compilers I'm def doing Turing as my final project lol.
XZNZ
Posted: Sun May 15, 2011 7:52 pm Post subject: RE:More efficient 360 degree movement + distance formula?
nice
XZNZ
Posted: Sun May 15, 2011 8:43 pm Post subject: RE:More efficient 360 degree movement + distance formula?
hey
without using sqrt function multiply by 0.5
and
x * x instead of x^2 will save a lot of time