OSDN Git Service

Changed to match the For2.2.2-Refactoring-Cocoa2 branch. Put se_maoudamashii_voice_m...
[hengbandforosx/hengbandosx.git] / src / geometry.c
1 #include "angband.h"
2
3 /*!
4  * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
5  * Convert an adjacent location to a direction.
6  * @param y 方角を確認したY座標
7  * @param x 方角を確認したX座標
8  * @return 方向ID
9  */
10 DIRECTION coords_to_dir(POSITION y, POSITION x)
11 {
12         DIRECTION d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
13         POSITION dy, dx;
14
15         dy = y - p_ptr->y;
16         dx = x - p_ptr->x;
17         if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
18
19         return d[dx + 1][dy + 1];
20 }