- Pareix que PER FI la ordenació es 100% correcta! HURRA!!

This commit is contained in:
2023-03-08 20:01:38 +01:00
parent a9cafc7c76
commit 82fc3f3c98
4 changed files with 25 additions and 18 deletions

View File

@@ -83,7 +83,7 @@ namespace actor
void setDirty(actor_t *act, const bool force)
{
/*
if (act->prev==nullptr && act != first && !force) return;
if (act->prev) act->prev->next = act->next;
@@ -93,20 +93,26 @@ namespace actor
act->prev = nullptr;
act->next = dirty;
dirty = act;
*/
}
void insert(actor_t *act)
{
act->next = first;
first = act;
const bool isInFront(actor_t *act1, actor_t *act2) {
if (act1->pos.x >= act2->pos.x+act2->size.x) { return true; }
else if (act2->pos.x >= act1->pos.x+act1->size.x) { return false; }
if (act1->pos.y >= act2->pos.y+act2->size.y) { return true; }
else if (act2->pos.y >= act1->pos.y+act1->size.y) { return false; }
if (act1->pos.z >= act2->pos.z+act2->size.z) { return true; }
else if (act2->pos.z >= act1->pos.z+act1->size.z) { return false; }
}
void reorder()
{
anim_frame=(anim_frame+1)%4;
dirty=first;
first=nullptr;
//dirty=first;
//first=nullptr;
while (dirty)
{
//const int z_index = dirty->pos.x + dirty->pos.y + dirty->pos.z;
@@ -119,7 +125,8 @@ namespace actor
//if ((dirty->pos.z < current->pos.z+current->size.z) && (current->pos.x+current->size.x+current->pos.y > dirty->pos.x+dirty->size.x+dirty->pos.y))
//if (current->pos.x+current->pos.y>dirty->pos.y+dirty->pos.x || current->pos.z+current->size.z>dirty->pos.z)
if (current->pos.x>dirty->pos.x+dirty->size.x || current->pos.y>dirty->pos.y+dirty->size.y || current->pos.z>dirty->pos.z+dirty->size.z)
//if (current->pos.x>dirty->pos.x+dirty->size.x || current->pos.y>dirty->pos.y+dirty->size.y || current->pos.z>dirty->pos.z+dirty->size.z)
if (isInFront(current, dirty))
{
dirty->prev = current->prev;
current->prev = dirty;
@@ -452,9 +459,12 @@ namespace actor
}
}
//int order=0;
void draw(actor_t *act, const bool draw_all)
{
if (!act) return;
//if (act==first)order=0;
//order++;
const int x = 148-act->bmp_offset.x + act->pos.x*2 - act->pos.y*2;
const int y = 91-act->bmp_offset.y + act->pos.x + act->pos.y - act->pos.z*2;
@@ -464,8 +474,10 @@ namespace actor
const int ao = (act->flags & FLAG_ANIMATED) ? anims[act->anim_cycle][anim_frame]*act->bmp_rect.w : 0;
draw::draw(x, y, act->bmp_rect.w, act->bmp_rect.h, act->bmp_rect.x+ao, act->bmp_rect.y+oo, flip);
//print(x,y,act->pos.x+act->pos.y);
//print(x+10,y,act->pos.z);
//print(x+5,y,act->pos.x);
//print(x+5,y+6,act->pos.y);
//print(x+5,y+12,order);
if (draw_all && act->next) draw(act->next);
}