- Ja picka i leava objectes, pero no se perque se perd el falg de pickable. BUG

- Roomba retocada per a no ser tan juggernaut
This commit is contained in:
2024-06-18 07:07:19 +02:00
parent e399e287ae
commit a648390f29
5 changed files with 83 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -90,7 +90,7 @@ actor{
name: ROOMBA
bmp: caixes.gif
bmp-rect: 160 0 32 32
bmp-offset: 0 32
bmp-offset: 0 34
pos: 40 32 0
size: 8 8 4
orient: YP

View File

@@ -17,6 +17,7 @@ namespace actor
actor_t *first = nullptr;
actor_t *dirty = nullptr;
actor_t *selected = nullptr;
actor_t *picked = nullptr;
actor_t *getFirst()
{
@@ -220,7 +221,7 @@ namespace actor
{
tmp[0]=0;
if (value==0) return "NONE";
if (value&1) strcat(tmp, "HERO ");
if (value&256) strcat(tmp, "PICKABLE ");
if (value&2) strcat(tmp, "PUSHABLE ");
if (value&4) strcat(tmp, "REACTIVE ");
if (value&8) strcat(tmp, "MOVING ");
@@ -285,6 +286,7 @@ namespace actor
other = other->next;
if (other == act) other = other->next;
}
/*
other = dirty;
while (other)
{
@@ -292,6 +294,7 @@ namespace actor
other = other->next;
if (other == act) other = other->next;
}
*/
return nullptr;
}
@@ -304,6 +307,7 @@ namespace actor
other = other->next;
if (other == act) other = other->next;
}
/*
other = dirty;
while (other)
{
@@ -311,12 +315,19 @@ namespace actor
other = other->next;
if (other == act) other = other->next;
}
*/
return nullptr;
}
void setDirty(actor_t *act, const bool force)
{
if (!act->prev && !act->next)
{
act->next = first;
if (first) first->prev = act;
first = act;
}
/*
if (act->prev==nullptr && act != first && !force) return;
if (act->prev) act->prev->next = act->next;
@@ -326,7 +337,7 @@ namespace actor
act->prev = nullptr;
act->next = dirty;
dirty = act;
*/
}
void select(actor_t *act) {
@@ -346,6 +357,9 @@ namespace actor
void reorder()
{
dirty = first;
first = nullptr;
while (dirty)
{
if (first)
@@ -473,6 +487,34 @@ namespace actor
act->push |= PUSH_YP;
}
}
if (input::keyPressed(SDL_SCANCODE_RETURN))
{
if (picked)
{
picked->pos.x = act->pos.x;
picked->pos.y = act->pos.y;
picked->pos.z = act->pos.z;
act->pos.z += picked->size.z;
actor::actor_t *above = act->above;
while (above) { above->pos.z += picked->size.z; above = above->above; }
if (act->below)
{
act->below->above = picked;
picked->below = act->below;
}
act->below = picked;
picked->above = act;
picked->next = picked->prev = nullptr;
actor::setDirty(picked, true);
picked = nullptr;
}
else if (act->below && act->below->flags&FLAG_PICKABLE)
{
const int height = act->below->size.z;
pick(act->below);
if (!input::keyDown(SDL_SCANCODE_SPACE)) act->pos.z -= height;
}
}
if ( input::keyDown(SDL_SCANCODE_SPACE) && (act->pos.y+act->size.y)<=max.y && act->pos.y>=min.y && (act->pos.x+act->size.x)<=max.x && act->pos.x>=min.x && act->react_mask==0 && (act->pos.z==0 || act->below))
{
// [RZC 14/05/2024] hack usant react_mask i react_push del heroi. Llegir més avall.
@@ -793,6 +835,8 @@ namespace actor
void update(actor_t *act, const bool update_all)
{
if (!act) return;
actor_t *next = act->next;
// Actualitzem el frame de l'animació (si no te el flag de animat, no afectarà per a res)
@@ -819,6 +863,8 @@ namespace actor
void updateEditor(actor_t *act, const bool update_all)
{
if (!act) return;
actor_t *next = act->next;
if (act->anim_wait_count==act->anim_wait) {
@@ -892,6 +938,7 @@ namespace actor
act = act->next;
}
/*
act = dirty;
while (act)
{
@@ -901,6 +948,7 @@ namespace actor
}
act = act->next;
}
*/
return nullptr;
}
@@ -932,6 +980,7 @@ namespace actor
other = other->next;
}
/*
other = dirty;
while (other)
{
@@ -944,6 +993,7 @@ namespace actor
}
other = other->next;
}
*/
return nullptr;
}
@@ -970,6 +1020,21 @@ namespace actor
free(act);
}
void pick(actor_t *act)
{
if (!act) return;
if (act->prev) act->prev->next = act->next;
if (act==first) first = act->next;
if (act==dirty) dirty = act->next;
if (act->next) act->next->prev = act->prev;
if (act==selected) selected = nullptr;
picked = act;
picked->pos.x=36;
picked->pos.y=82;
}
actor_t *getPicked() { return picked; }
void clear()
{
actor_t *hero = nullptr;
@@ -985,6 +1050,7 @@ namespace actor
}
act = tmp;
}
/*
act = dirty;
while (act)
{
@@ -997,10 +1063,16 @@ namespace actor
}
act = tmp;
}
*/
if (picked)
{
free(picked);
picked = nullptr;
}
first = dirty = nullptr;
if (hero) {
hero->above = hero->below = hero->next = hero->prev = nullptr;
dirty = hero;
first = hero;
}
selected = nullptr;
}

View File

@@ -123,6 +123,10 @@ namespace actor
void remove(actor_t *act);
void pick(actor_t *act);
actor_t *getPicked();
void clear();
namespace templates

View File

@@ -365,6 +365,8 @@ bool game::loop()
room::draw();
actor::draw(actor::getFirst());
room::draw2();
draw::swapcol(1, WHITE+LIGHT);
actor::draw(actor::getPicked(), false);
//draw::draw(148+sx*2-sy*2, 67+sx+sy,24,24,24,0);
/*