00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "rope.h"
00021
00030 Rope::Rope(spriteManager *newsm, bool isCap) : spriteObject(newsm), childGFX(0)
00031 {
00032 #ifdef __MDDEBUG
00033 className = "rope";
00034 macros::debugMessage(className, "constructor");
00035 #endif
00036 if (isCap)
00037 {
00038 setBounds(-8, 8, 8, -8);
00039 setFrame(4);
00040 setCollision(COL_NONE);
00041 } else {
00042 setBounds(-8, 0, 8, 0);
00043 setFrame(5);
00044 setCollision(COL_SOLID);
00045 }
00046 setLayer(2);
00047 }
00048
00049 Rope::~Rope()
00050 {
00051
00052 }
00053
00058 void Rope::makeStatic()
00059 {
00060 for (u8 i=0; i<childRopes.size(); ++i)
00061 childRopes[i]->makeStatic();
00062 spriteObject::makeStatic();
00063 }
00064
00071 bool Rope::setLength(u8 numRopes)
00072 {
00073 if (numRopes > childRopes.size())
00074 {
00075 for (u8 i=childRopes.size(); i<numRopes; ++i)
00076 {
00077 Rope * temp = new Rope(sm, false);
00078 temp->setPallete(palleteID);
00079 temp->giveGFX(childGFX, OBJ_SIZE_16X16, 8, 8);
00080 temp->setPos(getx(), gety() + centery*2*(i+1));
00081 temp->parentRope = this;
00082 childRopes.push_back(temp);
00083
00084 }
00085 } else if (numRopes < childRopes.size())
00086 {
00087 for (u8 i=childRopes.size()-1; i>=numRopes; i--)
00088 delete childRopes[i];
00089 childRopes.erase(childRopes.end() - numRopes, childRopes.end());
00090
00091 }
00092 return true;
00093 }
00094
00098 void Rope::setPos(s16 nx, s16 ny)
00099 {
00100 spriteObject::setPos(nx, ny);
00101 for (u8 i=0; i<childRopes.size(); ++i)
00102 {
00103 childRopes[i]->setPos(nx, ny + centery*2*(i+1));
00104 }
00105 }