1 /*
2  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  */
9 #include "Dir.h"
10 
11 #include <assert.h>
12 
13 //-----------------------------------------------------------------
14 /**
15  * Convert dir to relative coordinations.
16  */
17 V2
dir2xy(eDir dir)18 Dir::dir2xy(eDir dir)
19 {
20     int x = 0;
21     int y = 0;
22     switch (dir) {
23         case DIR_UP:
24             y = -1;
25             break;
26         case DIR_DOWN:
27             y = +1;
28             break;
29         case DIR_LEFT:
30             x = -1;
31             break;
32         case DIR_RIGHT:
33             x = +1;
34             break;
35         case DIR_NO:
36             break;
37         default:
38             assert(!"unknown dir");
39             break;
40     }
41 
42     return V2(x, y);
43 }
44 
45