|
|
|
#include "object.h"
|
|
|
|
|
|
|
|
extern std::vector<Object*> OBJECTS;
|
|
|
|
|
|
|
|
void Object::Move(vd2d move) {
|
|
|
|
if (move.y==0) {
|
|
|
|
pos+=move;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
if (move.y<0) {
|
|
|
|
while (objArrElement>0&&OBJECTS[objArrElement-1]->pos.y+OBJECTS[objArrElement-1]->originPoint.y>pos.y+originPoint.y+move.y) {
|
|
|
|
//printf("%p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement-1],OBJECTS[objArrElement-1]->name.c_str());
|
|
|
|
OBJECTS[objArrElement]=OBJECTS[objArrElement-1];
|
|
|
|
//printf(" %p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement-1],OBJECTS[objArrElement-1]->name.c_str());
|
|
|
|
OBJECTS[objArrElement-1]=this;
|
|
|
|
//printf(" %p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement-1],OBJECTS[objArrElement-1]->name.c_str());
|
|
|
|
OBJECTS[objArrElement]->objArrElement=objArrElement;
|
|
|
|
//printf(" %p(%s)(%d)<->%p(%s)(%d)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement]->objArrElement,OBJECTS[objArrElement-1],OBJECTS[objArrElement-1]->name.c_str(),objArrElement-1);
|
|
|
|
objArrElement--;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while (objArrElement<OBJECTS.size()-1&&OBJECTS[objArrElement+1]->pos.y+OBJECTS[objArrElement+1]->originPoint.y<pos.y+originPoint.y+move.y) {
|
|
|
|
//printf("%p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement+1],OBJECTS[objArrElement+1]->name.c_str());
|
|
|
|
OBJECTS[objArrElement]=OBJECTS[objArrElement+1];
|
|
|
|
//printf(" %p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement+1],OBJECTS[objArrElement+1]->name.c_str());
|
|
|
|
OBJECTS[objArrElement+1]=this;
|
|
|
|
//printf(" %p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement+1],OBJECTS[objArrElement+1]->name.c_str());
|
|
|
|
OBJECTS[objArrElement]->objArrElement=objArrElement;
|
|
|
|
//printf(" %p(%s)(%d)<->%p(%s)(%d)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement]->objArrElement,OBJECTS[objArrElement+1],OBJECTS[objArrElement+1]->name.c_str(),objArrElement+1);
|
|
|
|
objArrElement++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pos+=move;
|
|
|
|
}
|
|
|
|
}
|