- ordenacio correcta

- tiles de 32 pixels
This commit is contained in:
2023-03-01 20:09:46 +01:00
parent 7a2bf7fa43
commit 53212f4bfa
4 changed files with 24 additions and 26 deletions

View File

@@ -11,7 +11,7 @@ namespace actor
return first;
}
actor_t *create(pos_t p, size_t s, SDL_Rect r, SDL_Point o)
actor_t *create(vec3_t p, vec3_t s, SDL_Rect r, SDL_Point o)
{
actor_t *act = (actor_t*)malloc(sizeof(actor_t));
act->pos = p;
@@ -36,14 +36,24 @@ namespace actor
{
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;
if (first)
{
actor_t *current = first;
while (true)
{
const int z_index2 = current->pos.x + current->pos.y + current->pos.z;
if (z_index > z_index2)
//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))
{
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)
{
@@ -58,15 +68,6 @@ namespace actor
break;
}
}
else
{
dirty->prev = current->prev;
current->prev = dirty;
if (dirty->prev) dirty->prev->next = dirty;
dirty = dirty->next;
current->prev->next = current;
break;
}
}
}
else
@@ -82,7 +83,7 @@ namespace actor
{
if (!act) return;
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;
const int y = 91-act->bmp_offset.y + act->pos.x + act->pos.y - act->pos.z*2;
draw::draw(x, y, act->bmp_rect.w, act->bmp_rect.h, act->bmp_rect.x, act->bmp_rect.y);
if (draw_all && act->next) draw(act->next);
}