author | tron |
Sun, 05 Mar 2006 12:34:55 +0000 | |
changeset 3147 | fc76d566a68e |
child 3148 | 96d6a2fa97df |
permissions | -rw-r--r-- |
3147
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
2 |
|
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
3 |
#ifndef DIRECTION_H |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
4 |
#define DIRECTION_H |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
5 |
|
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
6 |
/* Direction as commonly used in v->direction, 8 way. */ |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
7 |
typedef enum Direction { |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
8 |
DIR_N = 0, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
9 |
DIR_NE = 1, /* Northeast, upper right on your monitor */ |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
10 |
DIR_E = 2, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
11 |
DIR_SE = 3, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
12 |
DIR_S = 4, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
13 |
DIR_SW = 5, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
14 |
DIR_W = 6, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
15 |
DIR_NW = 7, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
16 |
DIR_END, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
17 |
INVALID_DIR = 0xFF, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
18 |
} Direction; |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
19 |
|
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
20 |
|
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
21 |
/* Direction commonly used as the direction of entering and leaving tiles, 4-way */ |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
22 |
typedef enum DiagDirection { |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
23 |
DIAGDIR_NE = 0, /* Northeast, upper right on your monitor */ |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
24 |
DIAGDIR_SE = 1, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
25 |
DIAGDIR_SW = 2, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
26 |
DIAGDIR_NW = 3, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
27 |
DIAGDIR_END, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
28 |
INVALID_DIAGDIR = 0xFF, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
29 |
} DiagDirection; |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
30 |
|
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
31 |
static inline DiagDirection ReverseDiagDir(DiagDirection d) |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
32 |
{ |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
33 |
return 2 ^ d; |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
34 |
} |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
35 |
|
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
36 |
|
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
37 |
static inline DiagDirection DirToDiagdir(Direction dir) |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
38 |
{ |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
39 |
return (DiagDirection)(dir >> 1); |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
40 |
} |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
41 |
|
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
42 |
|
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
43 |
/* the 2 axis */ |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
44 |
typedef enum Axis { |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
45 |
AXIS_X = 0, |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
46 |
AXIS_Y = 1 |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
47 |
} Axis; |
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
48 |
|
fc76d566a68e
(svn r3767) Move all direction related enums and functions to a separate header
tron
parents:
diff
changeset
|
49 |
#endif |