- Tractant d'arreglar l'ordenació

This commit is contained in:
2023-03-08 19:03:15 +01:00
parent 43228c3809
commit a9cafc7c76
3 changed files with 19 additions and 2 deletions

View File

@@ -83,6 +83,7 @@ namespace actor
void setDirty(actor_t *act, const bool force) void setDirty(actor_t *act, const bool force)
{ {
/*
if (act->prev==nullptr && act != first && !force) return; if (act->prev==nullptr && act != first && !force) return;
if (act->prev) act->prev->next = act->next; if (act->prev) act->prev->next = act->next;
@@ -92,12 +93,20 @@ namespace actor
act->prev = nullptr; act->prev = nullptr;
act->next = dirty; act->next = dirty;
dirty = act; dirty = act;
*/
}
void insert(actor_t *act)
{
act->next = first;
first = act;
} }
void reorder() void reorder()
{ {
anim_frame=(anim_frame+1)%4; anim_frame=(anim_frame+1)%4;
dirty=first;
first=nullptr;
while (dirty) while (dirty)
{ {
//const int z_index = dirty->pos.x + dirty->pos.y + dirty->pos.z; //const int z_index = dirty->pos.x + dirty->pos.y + dirty->pos.z;
@@ -108,7 +117,9 @@ namespace actor
{ {
//const int z_index2 = current->pos.x + current->pos.y + current->pos.z; //const int z_index2 = current->pos.x + current->pos.y + current->pos.z;
//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 ((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>dirty->pos.z)
//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)
{ {
dirty->prev = current->prev; dirty->prev = current->prev;
current->prev = dirty; current->prev = dirty;

View File

@@ -67,6 +67,8 @@ namespace actor
actor_t *create(vec3_t p, vec3_t s, SDL_Rect r, SDL_Point o); actor_t *create(vec3_t p, vec3_t s, SDL_Rect r, SDL_Point o);
void setDirty(actor_t *act, const bool force=false); void setDirty(actor_t *act, const bool force=false);
void insert(actor_t *act);
void reorder(); void reorder();

View File

@@ -20,16 +20,20 @@ void game::init()
box->movement = MOV_Z; box->movement = MOV_Z;
box->mov_push = PUSH_ZP; box->mov_push = PUSH_ZP;
actor::setDirty(box, true); actor::setDirty(box, true);
actor::insert(box);
box = actor::create({32,32,16}, {8,8,8}, {32,0,32,32}, {0,32}); box = actor::create({32,32,16}, {8,8,8}, {32,0,32,32}, {0,32});
box->flags = FLAG_PUSHABLE | FLAG_GRAVITY; box->flags = FLAG_PUSHABLE | FLAG_GRAVITY;
box->movement = MOV_CW; box->movement = MOV_CW;
box->mov_push = PUSH_XN; box->mov_push = PUSH_XN;
actor::setDirty(box, true); actor::setDirty(box, true);
actor::insert(box);
box = actor::create({16,16,8}, {8,8,8}, {0,32,20,32}, {-6,38}); box = actor::create({16,16,8}, {8,8,8}, {0,32,20,32}, {-6,38});
box->flags = FLAG_HERO | FLAG_PUSHABLE | FLAG_GRAVITY | FLAG_ORIENTABLE | FLAG_ANIMATED; box->flags = FLAG_HERO | FLAG_PUSHABLE | FLAG_GRAVITY | FLAG_ORIENTABLE | FLAG_ANIMATED;
actor::setDirty(box, true); actor::setDirty(box, true);
actor::insert(box);
actor::reorder(); actor::reorder();
} }