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

Go to the documentation of this file.
00001 #include "EventPoint.h"
00002 #include "CommandManager.h"
00003 #include "List.h"
00004 #include "Parser.h"
00005 #include "Sprite.h"
00006 #include <iostream>
00007 
00008 using namespace std;
00009 
00010 EventPoint::EventPoint(List* info, int x, int y)
00011 :Object(info,x,y),_active(true),_collideEvent(false),_hasSprite(false),_collideList(NULL)
00012 {
00013         _collidable = true;
00014         _type = EVENTPOINT;
00015 
00016         //FIXME make me load this in
00017         //_box.h = 32;
00018         //_box.w = 32;
00019 
00020         load(info);
00021 }
00022 
00023 EventPoint::~EventPoint()
00024 {
00025         delete _collideList;
00026 }
00027 
00028 void EventPoint::load(List *info)
00029 {
00030         while(!info->empty()) {
00031                 List *current = info->firstList();
00032 
00033                 if(current->firstString() == "collideScript") {
00034                         if(current->rest()->first()->atomic()) {
00035                                 string collideFile = current->rest()->firstString();
00036                                 _collideList = Parser::parse(collideFile);
00037                         }
00038                         else {
00039                                 _collideList = new List(current->rest()->firstList());
00040                         }
00041                         _collideEvent = true;
00042                 }
00043                 else if(current->firstString() == "sprite") {
00044                         _sprite = Sprite::loadSprite(current->rest()->firstString());
00045                         _hasSprite = true;
00046                         _box.h = _sprite->height();
00047                         _box.w = _sprite->width();
00048                 }
00049                 else if(current->firstString() == "replace") {
00050                         findAndReplace(current->rest()->firstString(), current->rest()->rest()->firstString());
00051                 }
00052 
00053                 info = info->rest();
00054         }
00055 
00056 }
00057 
00058 void EventPoint::collide(Object *o)
00059 {
00060         if(o->getType() == PLAYER && _active && _collideEvent) {
00061                 CommandManager::instance()->startPlaying(_collideList);
00062                 _active = false;
00063         }
00064 }
00065 
00066 void EventPoint::findAndReplace(std::string find, std::string replace)
00067 {
00068         if(_collideEvent) {
00069                 _collideList->findAndReplace(find,replace);
00070         }
00071 }
00072 
00073 void EventPoint::draw()
00074 {
00075         if(_hasSprite && _active)
00076                 _sprite->draw(_box.x,_box.y);
00077 }

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