- [FIX] He pogut evitar la major part dels parpadejos de ordenar actors
This commit is contained in:
@@ -345,8 +345,20 @@ namespace actor
|
|||||||
selected = act;
|
selected = act;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool isInFront(actor_t *act1, actor_t *act2) {
|
const bool overlap(actor_t *act1, actor_t *act2)
|
||||||
|
{
|
||||||
|
return act1->inner_x < act2->inner_x+act2->bmp_rect.w &&
|
||||||
|
act1->inner_x+act1->bmp_rect.w > act2->inner_x &&
|
||||||
|
act1->inner_y > act2->inner_y+act2->bmp_rect.h &&
|
||||||
|
act1->inner_y+act1->bmp_rect.h < act2->inner_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool isInFront(actor_t *act1, actor_t *act2)
|
||||||
|
{
|
||||||
|
return (act1->pos.x >= act2->pos.x+act2->size.x) ||
|
||||||
|
(act1->pos.y >= act2->pos.y+act2->size.y) ||
|
||||||
|
(act1->pos.z >= act2->pos.z+act2->size.z);
|
||||||
|
/*
|
||||||
if (act1->pos.x >= act2->pos.x+act2->size.x) { return true; }
|
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; }
|
else if (act2->pos.x >= act1->pos.x+act1->size.x) { return false; }
|
||||||
else if (act1->pos.y >= act2->pos.y+act2->size.y) { return true; }
|
else if (act1->pos.y >= act2->pos.y+act2->size.y) { return true; }
|
||||||
@@ -354,6 +366,7 @@ namespace actor
|
|||||||
else if (act1->pos.z >= act2->pos.z+act2->size.z) { return true; }
|
else 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; }
|
else if (act2->pos.z >= act1->pos.z+act1->size.z) { return false; }
|
||||||
else { return false; }
|
else { return false; }
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void reorder()
|
void reorder()
|
||||||
@@ -363,22 +376,15 @@ namespace actor
|
|||||||
|
|
||||||
while (dirty)
|
while (dirty)
|
||||||
{
|
{
|
||||||
|
dirty->inner_x = 148-dirty->bmp_offset.x + dirty->pos.x*2 - dirty->pos.y*2;
|
||||||
|
dirty->inner_y = 91-dirty->bmp_offset.y + dirty->pos.x + dirty->pos.y - dirty->pos.z*2;
|
||||||
|
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
actor_t *current = first;
|
actor_t *current = first;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (isInFront(current, dirty))
|
if (overlap(dirty, current) || isInFront(dirty, current))
|
||||||
{
|
|
||||||
dirty->prev = current->prev;
|
|
||||||
current->prev = dirty;
|
|
||||||
if (dirty->prev) dirty->prev->next = dirty;
|
|
||||||
dirty = dirty->next;
|
|
||||||
current->prev->next = current;
|
|
||||||
if (current==first) first=current->prev;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (current->next)
|
if (current->next)
|
||||||
{
|
{
|
||||||
@@ -393,6 +399,16 @@ namespace actor
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dirty->prev = current->prev;
|
||||||
|
current->prev = dirty;
|
||||||
|
if (dirty->prev) dirty->prev->next = dirty;
|
||||||
|
dirty = dirty->next;
|
||||||
|
current->prev->next = current;
|
||||||
|
if (current==first) first=current->prev;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -909,8 +925,8 @@ namespace actor
|
|||||||
|
|
||||||
if (!editor::isEditing() || ( (act->flags&FLAG_HERO)==0))
|
if (!editor::isEditing() || ( (act->flags&FLAG_HERO)==0))
|
||||||
{
|
{
|
||||||
const int x = 148-act->bmp_offset.x + act->pos.x*2 - act->pos.y*2;
|
const int x = act->inner_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;
|
const int y = act->inner_y; // 91-act->bmp_offset.y + act->pos.x + act->pos.y - act->pos.z*2;
|
||||||
|
|
||||||
const bool flip = ( (act->flags & FLAG_ORIENTABLE) && (act->orient==PUSH_XN || act->orient==PUSH_YP) ) ? DRAW_FLIP_HORIZONTAL : DRAW_FLIP_NONE;
|
const bool flip = ( (act->flags & FLAG_ORIENTABLE) && (act->orient==PUSH_XN || act->orient==PUSH_YP) ) ? DRAW_FLIP_HORIZONTAL : DRAW_FLIP_NONE;
|
||||||
const int oo = ( (act->flags & FLAG_ORIENTABLE) && (act->orient==PUSH_XN || act->orient==PUSH_YN) ) ? act->bmp_rect.h : 0;
|
const int oo = ( (act->flags & FLAG_ORIENTABLE) && (act->orient==PUSH_XN || act->orient==PUSH_YN) ) ? act->bmp_rect.h : 0;
|
||||||
@@ -1037,6 +1053,9 @@ namespace actor
|
|||||||
picked = act;
|
picked = act;
|
||||||
picked->pos.x=36;
|
picked->pos.x=36;
|
||||||
picked->pos.y=82;
|
picked->pos.y=82;
|
||||||
|
picked->inner_x = 148-act->bmp_offset.x + act->pos.x*2 - act->pos.y*2;
|
||||||
|
picked->inner_y = 91-act->bmp_offset.y + act->pos.x + act->pos.y - act->pos.z*2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actor_t *getPicked() { return picked; }
|
actor_t *getPicked() { return picked; }
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ namespace actor
|
|||||||
|
|
||||||
actor_t *prev;
|
actor_t *prev;
|
||||||
actor_t *next;
|
actor_t *next;
|
||||||
|
|
||||||
|
int inner_x;
|
||||||
|
int inner_y;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Torna el primer actor de la llista
|
// Torna el primer actor de la llista
|
||||||
|
|||||||
@@ -354,14 +354,14 @@ bool game::loop()
|
|||||||
actor::update(actor::getFirst());
|
actor::update(actor::getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
actor::reorder();
|
|
||||||
editor_select_by_keyboard();
|
|
||||||
|
|
||||||
draw::resetViewport();
|
draw::resetViewport();
|
||||||
draw::cls(2);
|
draw::cls(2);
|
||||||
|
|
||||||
draw::setViewport(100,0,320,240);
|
draw::setViewport(100,0,320,240);
|
||||||
|
|
||||||
|
actor::reorder();
|
||||||
|
editor_select_by_keyboard();
|
||||||
|
|
||||||
room::draw();
|
room::draw();
|
||||||
actor::draw(actor::getFirst());
|
actor::draw(actor::getFirst());
|
||||||
room::draw2();
|
room::draw2();
|
||||||
|
|||||||
Reference in New Issue
Block a user