- El heroi es independent de la recarrega

This commit is contained in:
2023-06-06 19:36:45 +02:00
parent 33d9573d8a
commit e75eae0c7e
2 changed files with 30 additions and 6 deletions

View File

@@ -640,13 +640,34 @@ namespace actor
void clear() void clear()
{ {
actor_t *hero = nullptr;
actor_t *act = first; actor_t *act = first;
while (act) while (act)
{ {
actor_t *tmp = act->next; actor_t *tmp = act->next;
free(act); if (act->flags & FLAG_HERO) {
hero = act;
} else {
free(act);
}
act = tmp;
}
act = dirty;
while (act)
{
actor_t *tmp = act->next;
if (act->flags & FLAG_HERO) {
hero = act;
} else {
free(act);
}
act = tmp; act = tmp;
} }
first = dirty = nullptr; first = dirty = nullptr;
if (hero) {
hero->above = hero->below = hero->next = hero->prev = nullptr;
dirty = hero;
}
} }
} }

View File

@@ -7,7 +7,6 @@
#include "jui.h" #include "jui.h"
draw::surface *surf; draw::surface *surf;
actor::actor_t *box;
int room_w = 2; int room_w = 2;
int room_h = 2; int room_h = 2;
int room_xp = -1; int room_xp = -1;
@@ -28,15 +27,15 @@ void restart()
actor::setDirty(box, true); actor::setDirty(box, true);
*/ */
box = actor::create("BOX", {32,32,16}, {8,8,8}, {32,0,32,32}, {0,32}); actor::actor_t *box = actor::create("BOX", {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);
box = actor::create("HERO", {16,32,8}, {8,8,12}, {0,32,20,32}, {-6,38}); //box = actor::create("HERO", {16,32,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::reorder(); actor::reorder();
} }
@@ -49,6 +48,10 @@ void game::init()
draw::loadPalette("test.gif"); draw::loadPalette("test.gif");
game::setUpdateTicks(64); game::setUpdateTicks(64);
actor::actor_t *hero = actor::create("HERO", {16,32,8}, {8,8,12}, {0,32,20,32}, {-6,38});
hero->flags = FLAG_HERO | FLAG_PUSHABLE | FLAG_GRAVITY | FLAG_ORIENTABLE | FLAG_ANIMATED;
actor::setDirty(hero, true);
restart(); restart();
} }