Compass display
Displaying 1-2 of 2 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Alexei

Hey everyone. A feature I'm playing with for the toy RPG I'm working on is a compass that will point to areas of interest (shamelessly stolen from Grandia). I *think* the best way to go about this is to create three points:

A = Player's XY coords
B = Interesting thing's XY coord's
X = Created point

such that a right triangle is formed, the 90-degree angle being A-X-B. I would then also have the lengths of sides A to X and X to B.

From there, I just need to determine the internal angle of the vertice at point A, and then plug it into RotScale.

Could someone help me fill in the gaps or at least point me to a site that speaks bloody english? Math is not my friend, unfortunately...

Posted on 2008-09-07 17:50:54 (last edited on 2008-09-07 17:55:22)

glambourine

So let's call the coordinates of point A (a, b) and the coordinates of point B (x, y), for fun. Then point X should be at (x-a, y-b).

If you plug numbers into this, you'll see that the x-coordinate of point X will be positive northeast and southeast of point A and negative northwest and southwest. The y-coordinate will be positive northeast and northwest and negative southeast and southwest. I only include this information because it took me like forever to figure it out the last time I had to do something like this in VERGE.

So the formula for finding the internal angle A' is just:

tan A' = opposite length / adjacent length

or:

tan A' = (y - (y - b)) / (x - (x - a))

which reduces I think to

tan A' = b / a

So then to find A, you use the inverse tangent. The function you want in VERGE is atan2, described here: http://verge-rpg.com/docs/view.php?libid=1&function=171

Possible bugs you'll encounter with this include: the problem with situations when point B is directly north, east, west, or south of point A, weird issues with converting between on-screen coordinates and map coordinates (some of the graphics functions use one, some use the other), and above all issues with fixed-point notation. I use some of this stuff in the game I'm working on and I still have some bugs related to it with all of those situations, so, um, I can't really explain how to solve these problems yet. But the stuff above is the basic unrefined math you'd need, I think.

Posted on 2008-09-07 21:46:50


Displaying 1-2 of 2 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.