Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

Dir.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "Dir.h"
00010 
00011 #include <assert.h>
00012 
00013 //-----------------------------------------------------------------
00014 /**
00015  * Convert dir to relative coordinations.
00016  */
00017 V2
00018 Dir::dir2xy(eDir dir)
00019 {
00020     int x = 0;
00021     int y = 0;
00022     switch (dir) {
00023         case DIR_UP:
00024             y = -1;
00025             break;
00026         case DIR_DOWN:
00027             y = +1;
00028             break;
00029         case DIR_LEFT:
00030             x = -1;
00031             break;
00032         case DIR_RIGHT:
00033             x = +1;
00034             break;
00035         case DIR_NO:
00036             break;
00037         default:
00038             assert(!"unknown dir");
00039             break;
00040     }
00041 
00042     return V2(x, y);
00043 }
00044 

Generated on Wed Jun 1 09:54:30 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2