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
00047 }
00048
00049 void Wall::draw(Point position, Point dimensions) const
00050 {
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
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