javascript - How does collisions caculates when developing game in Build an HTML5 Game book -


i don't understand authors login when calculating collisions between 2 circles (bubbles). here calculating collisions section.

author writes:

the bubble being fired follows set of coordinates defined equations:

px = ex + tdx py = ey + tdy

where px , py points on trajectory of bubble’s center point. calculation of px , py happens in jquery’s animate method , standard equation moving point along line. next, we’ll calculate t @ closest point on line center of bubble we’re checking against:

var t = dx * disttobubble.x + dy * disttobubble.y;

i don't understand t , why calculates following formula:

var t = dx * disttobubble.x + dy * disttobubble.y;?

this has little or nothing programming, absolutely math. think question shouldn't here, answer helping out.

i don't understand t

the line of movement of bubble being fired defined parametric equation, wich parameter variable t

why calculates following formula

this kind of complex, book shows final result of following calculation. there formula calculate distance between point , line. in case point center of target bubble , line represented parametric equiation shown. after solve that, can derive equation find minimum distance.

although there easier way solve this. using dot product between origin of target bubble , coordinates of shooted bubble parametric function , equal 0 (perpendicular intersection) cand find value t.

the important point here book solved problem , showing final result can use it.

good luck game!


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -