It uses the pythagorean theorem most likely.
a squared plus b squared is equal to c squared.
So in programming you would do this
a= sprite1x-sprite2x
b=sprite1y-sprite2y
c=square root ((a*a)+(b*b))
The distance between sprite1 and sprite2 is the c variable.
Offline
archmage wrote:
It uses the pythagorean theorem most likely.
a squared plus b squared is equal to c squared.
So in programming you would do this
a= sprite1x-sprite2x
b=sprite1y-sprite2y
c=square root ((a*a)+(b*b))
The distance between sprite1 and sprite2 is the c variable.
archmage thank you for this bit of info but seriously are you a accountant or something for a living? Because that math just makes by brain hurt.
Last edited by Sakani (2009-05-13 21:59:17)
Offline
Sakani, that is basic grade 9 math I think. It is pretty vital in programming because you can use it to find distances.
I think that I learned most of my algebra math in grade 9, and algebra is a vital thing to know for programming. What I explained was actually pretty simple but it is probably more difficult for those who have no concept of using variables or BEDMAS for mathematical equations.
Last edited by archmage (2009-05-13 22:05:05)
Offline
ye, i learned it last year.
anyways, its basicly this formula:
(2) means to the power of 2
distance(2) = x(2)-y(2)
so, distance = sqrRoot(x(2)-y(2) )
Last edited by yambanshee (2009-05-14 14:17:36)
Offline
archmage wrote:
Sakani, that is basic grade 9 math I think. It is pretty vital in programming because you can use it to find distances.
I think that I learned most of my algebra math in grade 9, and algebra is a vital thing to know for programming. What I explained was actually pretty simple but it is probably more difficult for those who have no concept of using variables or BEDMAS for mathematical equations.
It was actually basic grade 7 math
Offline
JSO wrote:
Grade 9...
What is the "default" age in grade 9? 14-15 or something?
Since in Belgium we have a completely different educational system...
It's 14-15 in Canada. A lot of people skip grades, though (I skipped a grade in Math, not the whole thing, so I'll be in grade 9 math next year even though I'll only be in grade 8).
Offline