00001 #include "Object.h"
00002 #include "Person.h"
00003 #include "Player.h"
00004 #include "Parser.h"
00005 #include "Enemy.h"
00006 #include "EventPoint.h"
00007 #include "CutScene.h"
00008 #include "Door.h"
00009
00010 Object::Object()
00011 :_depth( 0 ), _collidable( true )
00012 {
00013
00014 }
00015
00016 Object::Object(List* objInfo, int x, int y)
00017 :_depth( 0 ), _collidable( true )
00018 {
00019 _box.w = 32;
00020 _box.h = 32;
00021 _box.x = x;
00022 _box.y = y;
00023
00024 while( !objInfo->empty())
00025 {
00026 List * current = objInfo->firstList();
00027 if(current->firstString() == "id")
00028 _id = current->rest()->firstString();
00029 else if(current->firstString() == "size") {
00030 _box.w = current->rest()->firstInt();
00031 _box.h = current->rest()->rest()->firstInt();
00032 }
00033
00034 objInfo = objInfo->rest();
00035 }
00036 }
00037
00038 Object* Object::loadObject(std::string filename, int x , int y )
00039 {
00040 List* objInfo = Parser::parse(filename);
00041
00042 Object* returnme;
00043
00044
00045
00046
00047
00048 if(objInfo ->firstString() == "person")
00049 returnme = new Person(objInfo->rest(), x, y);
00050
00051 else if(objInfo ->firstString() == "player")
00052 returnme = new Player(objInfo->rest(), x, y);
00053
00054 else if(objInfo ->firstString() == "enemy")
00055 returnme = new Enemy(objInfo->rest(), x, y);
00056
00057 else if(objInfo ->firstString() == "eventpoint")
00058 returnme = new EventPoint(objInfo->rest(), x, y);
00059
00060 else if(objInfo ->firstString() == "cutscene")
00061 returnme = new CutScene(objInfo->rest(), x, y);
00062
00063 else if(objInfo ->firstString() == "door")
00064 returnme = new Door(objInfo->rest(), x, y);
00065
00066 delete objInfo;
00067 return returnme;
00068
00069 }