- Pareix que PER FI la ordenació es 100% correcta! HURRA!!
This commit is contained in:
BIN
data/test.gif
BIN
data/test.gif
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -83,7 +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;
|
||||||
@@ -93,20 +93,26 @@ namespace actor
|
|||||||
act->prev = nullptr;
|
act->prev = nullptr;
|
||||||
act->next = dirty;
|
act->next = dirty;
|
||||||
dirty = act;
|
dirty = act;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(actor_t *act)
|
const bool isInFront(actor_t *act1, actor_t *act2) {
|
||||||
{
|
|
||||||
act->next = first;
|
if (act1->pos.x >= act2->pos.x+act2->size.x) { return true; }
|
||||||
first = act;
|
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()
|
void reorder()
|
||||||
{
|
{
|
||||||
anim_frame=(anim_frame+1)%4;
|
anim_frame=(anim_frame+1)%4;
|
||||||
dirty=first;
|
//dirty=first;
|
||||||
first=nullptr;
|
//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;
|
||||||
@@ -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 ((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+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;
|
dirty->prev = current->prev;
|
||||||
current->prev = dirty;
|
current->prev = dirty;
|
||||||
@@ -452,9 +459,12 @@ namespace actor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//int order=0;
|
||||||
void draw(actor_t *act, const bool draw_all)
|
void draw(actor_t *act, const bool draw_all)
|
||||||
{
|
{
|
||||||
if (!act) return;
|
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 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 = 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;
|
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);
|
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+5,y,act->pos.x);
|
||||||
//print(x+10,y,act->pos.z);
|
//print(x+5,y+6,act->pos.y);
|
||||||
|
//print(x+5,y+12,order);
|
||||||
|
|
||||||
if (draw_all && act->next) draw(act->next);
|
if (draw_all && act->next) draw(act->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,6 @@ namespace actor
|
|||||||
|
|
||||||
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();
|
||||||
|
|
||||||
void update(actor_t *act, const bool update_all=true);
|
void update(actor_t *act, const bool update_all=true);
|
||||||
|
|||||||
@@ -16,23 +16,20 @@ void game::init()
|
|||||||
game::setUpdateTicks(64);
|
game::setUpdateTicks(64);
|
||||||
|
|
||||||
box = actor::create({16,16,0}, {8,8,4}, {64,0,32,24}, {0,24});
|
box = actor::create({16,16,0}, {8,8,4}, {64,0,32,24}, {0,24});
|
||||||
box->flags = FLAG_MOVING;// | FLAG_PUSHABLE;
|
box->flags = FLAG_MOVING;
|
||||||
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,12}, {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();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user