C:/Documents and Settings/mtauraso/Desktop/proj3/projectX/Door.cpp

Go to the documentation of this file.
00001 #include "Door.h"
00002 #include "List.h"
00003 
00004 Door::Door(List* info, int x, int y)
00005 :Object(info,x,y),_open(false),_locked(true)
00006 {
00007         _type = DOOR;
00008         load(info);
00009 }
00010 
00011 void Door::load(List *info)
00012 {
00013         while(!info->empty()) {
00014                 List *current = info->firstList();
00015 
00016                 if(current->firstString() == "openSprite") {
00017                         _openSprite = Sprite::loadSprite(current->rest()->firstString());
00018                 }
00019                 else if(current->firstString() == "closedSprite") {
00020                         _closedSprite = Sprite::loadSprite(current->rest()->firstString());
00021                 }
00022 
00023                 info = info->rest();
00024         }
00025 
00026         setOpen(_open);
00027 }
00028 
00029 void Door::collide( Object* o )
00030 {
00031         if(o->getType() == PLAYER && !_locked ) {
00032                 _open = true;
00033                 _collidable = false;
00034         }
00035 }
00036 
00037 void Door::draw()
00038 {
00039         if(_open)
00040                 _openSprite->draw(_box.x,_box.y);
00041         else
00042                 _closedSprite->draw(_box.x,_box.y);
00043                 
00044 }
00045 
00046 void Door::setOpen(bool open) 
00047 {
00048         _open = open;
00049         
00050         if(_open) {
00051                 _box.h = _openSprite->height();
00052                 _box.w = _openSprite->width();
00053                 _collidable = false;
00054         }
00055         else {
00056                 _box.h = _closedSprite->height();
00057                 _box.w = _closedSprite->width();
00058                 _collidable = true;
00059         }
00060 }

Generated on Sat Apr 22 15:05:20 2006 for ProjectX by  doxygen 1.4.6-NO