home *** CD-ROM | disk | FTP | other *** search
- #ifndef POSITION_H
- #define POSITION_H
-
- #include "Coord.h"
-
- class Direction
- {
- public:
- enum Dir { STAND, LEFT=1, UP=2, RIGHT=4, DOWN=8 };
-
- Direction()
- : dir( STAND )
- {}
-
- Direction( Dir dir )
- : dir( dir )
- {}
-
- bool operator== ( const Direction & d )const
- {
- return dir == d.dir;
- }
- bool operator!= ( const Direction & d )const
- {
- return !operator==( d );
- }
- bool is_opposed( const Direction & d )const
- {
- if( dir == LEFT && d.dir == RIGHT )
- return true;
- if( dir == RIGHT && d.dir == LEFT )
- return true;
- if( dir == UP && d.dir == DOWN )
- return true;
- if( dir == DOWN && d.dir == UP )
- return true;
- return false;
- }
- Dir get_dir()const
- {
- return dir;
- }
- private:
- Dir dir;
- };
-
- class Position
- {
- Coord src;
- Coord dst;
- float koef;
- int cell_size;
- public:
- friend class Level;
- Position()
- : src( 0, 0 ),
- dst( 0, 0 ),
- koef( 0 ),
- cell_size( 0 )
- {}
- Position( Coord src, Coord dst, int cell_size )
- : src( src ),
- dst( dst ),
- koef( 0 ),
- cell_size ( cell_size )
- {}
- bool go_to(float length);
- void swap_dst();
- int get_x()const
- {
- return int( src.x * (1-koef) + dst.x * koef + cell_size/2);
- }
- int get_y()const
- {
- return int( src.y * (1-koef) + dst.y * koef + cell_size/2);
- }
- };
-
- #endif //POSITION_H