D:/Development/Projects/X-Clone/X-Clone/trunk/Wall.cpp

Go to the documentation of this file.
00001 #include "Wall.h"
00002 #include "Display.h"
00003 
00004 #define WALL_IMAGE "images/wall.png"
00005 #define WALL_IMAGENE "images/wall-ne.png"
00006 #define WALL_IMAGENW "images/wall-nw.png"
00007 #define WALL_IMAGESE "images/wall-se.png"
00008 #define WALL_IMAGESW "images/wall-sw.png"
00009 
00010 SDL_Surface* Wall::_image = NULL;
00011 SDL_Surface* Wall::_imageNE = NULL;
00012 SDL_Surface* Wall::_imageNW = NULL;
00013 SDL_Surface* Wall::_imageSE = NULL;
00014 SDL_Surface* Wall::_imageSW = NULL;
00015 
00016 Wall::Wall(Direction dir) :
00017     _destroyed(false),
00018     _dir(dir)
00019 {
00020    if (!_image)
00021    {
00022       _image = Display::instance().loadImage(WALL_IMAGE);
00023       _imageNE = Display::instance().loadImage(WALL_IMAGENE);
00024       _imageNW = Display::instance().loadImage(WALL_IMAGENW);
00025       _imageSE = Display::instance().loadImage(WALL_IMAGESE);
00026       _imageSW = Display::instance().loadImage(WALL_IMAGESW);
00027    }
00028 }
00029 
00030 Wall::~Wall()
00031 {
00032 }
00033 
00034 bool Wall::isPassable() const
00035 {
00036     return true;
00037 }
00038 
00039 bool Wall::isPassable(Direction dir) const
00040 {
00041    return _destroyed || !(dir == _dir);
00042 }
00043 
00044 void Wall::destroy()
00045 {
00046    // @ todo fill in later
00047 }
00048 
00049 void Wall::draw(Point position, Point dimensions) const
00050 {
00051     // @ if not destroyed??
00052    //Display::instance().draw(position.x, position.y - (_image->h - dimensions.y), _image);
00053    /*
00054    switch ( _dir )
00055    {
00056        case NE:
00057             Display::instance().draw(position.x, position.y - (_image->h - dimensions.y), _imageNE);
00058             break;
00059        case NW:
00060             Display::instance().draw(position.x, position.y - (_image->h - dimensions.y), _imageNW);
00061             break;
00062        case SE:
00063             Display::instance().draw(position.x, position.y - (_image->h - dimensions.y), _imageSE);
00064             break;
00065        case SW:
00066             Display::instance().draw(position.x, position.y - (_image->h - dimensions.y), _imageSW);
00067             break;
00068 
00069    }
00070    */
00071     if ( _dir == Direction::NE )
00072             Display::instance().draw(position.x, position.y - (_image->h - dimensions.y), _imageNE);
00073     else if ( _dir == Direction::NW )
00074             Display::instance().draw(position.x, position.y - (_image->h - dimensions.y), _imageNW);
00075     else if ( _dir == Direction::SE )
00076             Display::instance().draw(position.x, position.y - (_image->h - dimensions.y), _imageSE);
00077     else if ( _dir == Direction::SW )
00078             Display::instance().draw(position.x, position.y - (_image->h - dimensions.y), _imageSW);
00079 }
00080 

Generated on Fri Sep 22 06:00:26 2006 for X-CLONE by  doxygen 1.4.7