- [NEW] Gràfics de explosió/fum
- [NEW] Gràfics de Robin - [NEW] Al agafar un booster / skill / part la pantalla fa colorets i es veu un fumet - [ONGOING] Comencem a implementar la perdua de vides. Ja fa el fumet, colorins i reseteja la pantalla...
This commit is contained in:
100
source/actor.cpp
100
source/actor.cpp
@@ -182,6 +182,24 @@ namespace actor
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
actor_t *replaceWithTemplate(actor_t *act, const char *name)
|
||||
{
|
||||
if (!act) return nullptr;
|
||||
actor_t *newactor = createFromTemplate(name);
|
||||
newactor->pos.x = act->pos.x;
|
||||
newactor->pos.y = act->pos.y;
|
||||
newactor->pos.z = act->pos.z;
|
||||
if (act->prev) act->prev->next = newactor;
|
||||
if (act==first) first = newactor;
|
||||
if (act==dirty) dirty = newactor;
|
||||
if (act->next) act->next->prev = newactor;
|
||||
newactor->prev = act->prev;
|
||||
newactor->next = act->next;
|
||||
act->prev = act->next = nullptr;
|
||||
remove(act);
|
||||
return newactor;
|
||||
}
|
||||
|
||||
char tmp[255];
|
||||
|
||||
// Li donem al actor un nom únic
|
||||
@@ -440,23 +458,26 @@ namespace actor
|
||||
uint8_t result = 0;
|
||||
if ( (act->flags & FLAG_PUSHABLE) && ( !(source->flags&FLAG_HERO) || (hero::getSkills()&SKILL_GLOVES) ) ) act->push |= push;
|
||||
if ( (act->flags & FLAG_REACTIVE) && (act->react_mask & push) ) result = act->react_push;
|
||||
if (act->flags & FLAG_DEADLY) result |= PUSH_KILL;
|
||||
if (source->flags & FLAG_DEADLY) {
|
||||
result |= PUSH_KILL;
|
||||
}
|
||||
|
||||
if (source->flags&FLAG_HERO)
|
||||
{
|
||||
if (act->flags & FLAG_SPECIAL)
|
||||
{
|
||||
// [TODO 02/07/2024] Fer que faça un fumet o algo al desapareixer les coses
|
||||
if (act->name[0]=='B') { // Es un booster
|
||||
hero::collectBooster(act->name[1]-48, (act->name[3]-48)*10+(act->name[4]-48));
|
||||
actor::remove(act);
|
||||
} else if (act->name[0]=='S') { // Es un skill
|
||||
hero::giveSkill(&act->name[2]);
|
||||
actor::remove(act);
|
||||
} else if ( (act->name[0]=='P') && (hero::getSkills()&SKILL_BAG) ) { // Es una part
|
||||
hero::pickPart(&act->name[2]);
|
||||
actor::remove(act);
|
||||
} else {
|
||||
SDL_assert(false);
|
||||
}
|
||||
act = actor::replaceWithTemplate(act, "EXPLOSION");
|
||||
act->name[0]='_';
|
||||
room::cycleColor(1);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -694,8 +715,17 @@ namespace actor
|
||||
vec3_t min = room::getMin();
|
||||
vec3_t max = room::getMax();
|
||||
|
||||
//if ((act->flags&FLAG_HERO) && (act->pos.x>max.x || act->pos.x<min.x || act->pos.y>max.y || act->pos.y<min.y) )
|
||||
//return;
|
||||
if ( (act->push & PUSH_KILL) && (act->flags & FLAG_HERO) ) {
|
||||
actor_t *act = actor::find("HERO");
|
||||
act = actor::replaceWithTemplate(act, "EXPLOSION");
|
||||
actor_t *act2 = actor::createFromTemplate("EXPLOSION");
|
||||
act2->pos = act->pos; act2->pos.z += 8; act2->anim_frame=2;
|
||||
act->anim_wait = act2->anim_wait = 1;
|
||||
actor::setDirty(act2);
|
||||
room::cycleColor(4);
|
||||
return;
|
||||
}
|
||||
|
||||
int vel = (act->flags&FLAG_HERO) && (hero::getBoostRun()>0) ? 2 : 1;
|
||||
|
||||
if (act->push & PUSH_ZP) {
|
||||
@@ -708,6 +738,7 @@ namespace actor
|
||||
room::load(room::getExit(ZP));
|
||||
act->pos.z = 4;
|
||||
actor::setDirty(act);
|
||||
hero::setFirstPos();
|
||||
room_changed = true;
|
||||
return;
|
||||
}
|
||||
@@ -728,6 +759,7 @@ namespace actor
|
||||
room::load(room::getExit(ZP));
|
||||
now->pos.z = 4;
|
||||
actor::setDirty(now);
|
||||
hero::setFirstPos();
|
||||
room_changed = true;
|
||||
return;
|
||||
}
|
||||
@@ -748,7 +780,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || ( act->pos.x<min.x && ( !(room::getDoors()&DOOR_XN) || (act->pos.y!=28) || (act->pos.z!=room::getDoor(XN)*4) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other) act->push |= push(act, other, PUSH_XN);
|
||||
if (other) other->push |= push(act, other, PUSH_XN);
|
||||
act->pos.x+=vel;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
if (act->flags & FLAG_INERTIA) act->push = PUSH_NONE;
|
||||
@@ -765,6 +797,7 @@ namespace actor
|
||||
room::load(room::getExit(XN));
|
||||
act->pos.x = room::getMax().x-4;
|
||||
act->pos.z = room::getDoor(XP)*4;
|
||||
hero::setFirstPos();
|
||||
room_changed = true;
|
||||
}
|
||||
|
||||
@@ -778,7 +811,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || ((act->pos.x+act->size.x)>max.x && ( !(room::getDoors()&DOOR_XP) || (act->pos.y!=28) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other) act->push |= push(act, other, PUSH_XP);
|
||||
if (other) other->push |= push(act, other, PUSH_XP);
|
||||
act->pos.x-=vel;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
if (act->flags & FLAG_INERTIA) act->push = PUSH_NONE;
|
||||
@@ -793,6 +826,7 @@ namespace actor
|
||||
room::load(room::getExit(XP));
|
||||
act->pos.x = room::getMin().x-3;
|
||||
act->pos.z = room::getDoor(XN)*4;
|
||||
hero::setFirstPos();
|
||||
room_changed = true;
|
||||
}
|
||||
|
||||
@@ -806,7 +840,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || ( act->pos.y<min.y && ( !(room::getDoors()&DOOR_YN) || (act->pos.x!=28) || (act->pos.z!=room::getDoor(YN)*4) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other) act->push |= push(act, other, PUSH_YN);
|
||||
if (other) other->push |= push(act, other, PUSH_YN);
|
||||
act->pos.y+=vel;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
if (act->flags & FLAG_INERTIA) act->push = PUSH_NONE;
|
||||
@@ -821,6 +855,7 @@ namespace actor
|
||||
room::load(room::getExit(YN));
|
||||
act->pos.y = room::getMax().y-4;
|
||||
act->pos.z = room::getDoor(YP)*4;
|
||||
hero::setFirstPos();
|
||||
room_changed = true;
|
||||
}
|
||||
|
||||
@@ -834,7 +869,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || ( (act->pos.y+act->size.y)>max.y && ( !(room::getDoors()&DOOR_YP) || (act->pos.x!=28) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other) act->push |= push(act, other, PUSH_YP);
|
||||
if (other) other->push |= push(act, other, PUSH_YP);
|
||||
act->pos.y-=vel;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
if (act->flags & FLAG_INERTIA) act->push = PUSH_NONE;
|
||||
@@ -849,6 +884,7 @@ namespace actor
|
||||
room::load(room::getExit(YP));
|
||||
act->pos.y = room::getMin().y-3;
|
||||
act->pos.z = room::getDoor(YN)*4;
|
||||
hero::setFirstPos();
|
||||
room_changed = true;
|
||||
}
|
||||
|
||||
@@ -868,6 +904,7 @@ namespace actor
|
||||
room::load(room::getExit(ZN));
|
||||
act->pos.z = room::getMax().z;
|
||||
actor::setDirty(act);
|
||||
hero::setFirstPos();
|
||||
room_changed = true;
|
||||
return;
|
||||
}
|
||||
@@ -878,7 +915,7 @@ namespace actor
|
||||
// ...i encara està baix...
|
||||
if (is_above(act, act->below)) {
|
||||
// ...li pase a ell el push, neteje el meu flag, canvie direcció si pertoca i me ane
|
||||
act->push |= push(act, act->below, PUSH_ZN);
|
||||
act->below->push |= push(act, act->below, PUSH_ZN);
|
||||
act->push &= ~PUSH_ZN;
|
||||
if ( (act->flags & FLAG_MOVING) && (act->movement==MOV_Z) ) changeMoving(act);
|
||||
return;
|
||||
@@ -898,7 +935,7 @@ namespace actor
|
||||
act->below = below;
|
||||
below->above = act;
|
||||
// ... i li passem el push, netejem el meu flag i gonnem
|
||||
act->push |= push(act, act->below, PUSH_ZN);
|
||||
act->below->push |= push(act, act->below, PUSH_ZN);
|
||||
act->push &= ~PUSH_ZN;
|
||||
if ( (act->flags & FLAG_MOVING) && (act->movement==MOV_Z) ) changeMoving(act);
|
||||
return;
|
||||
@@ -913,9 +950,6 @@ namespace actor
|
||||
actor::setDirty(act);
|
||||
}
|
||||
|
||||
if ( (act->push & PUSH_KILL) && (act->flags & FLAG_HERO) ) {
|
||||
//[TODO] Matar al ruiseñor
|
||||
}
|
||||
/*
|
||||
if (act->push & PUSH_ZN) {
|
||||
act->pos.z--;
|
||||
@@ -942,7 +976,16 @@ namespace actor
|
||||
|
||||
// Actualitzem el frame de l'animació (si no te el flag de animat, no afectarà per a res)
|
||||
if (act->anim_wait_count==act->anim_wait) {
|
||||
act->anim_frame=(act->anim_frame+1)%4;
|
||||
act->anim_frame=act->anim_frame+1;
|
||||
if (act->anim_frame==4) {
|
||||
if (act->name[0]=='_') {
|
||||
actor::remove(act);
|
||||
return;
|
||||
} else {
|
||||
act->anim_frame=0;
|
||||
}
|
||||
}
|
||||
if (act->anim_cycle==2 && act->anim_frame==3) act->anim_frame=0;
|
||||
act->anim_wait_count=0;
|
||||
} else {
|
||||
act->anim_wait_count++;
|
||||
@@ -1283,18 +1326,25 @@ namespace actor
|
||||
int skills = SKILL_NONE;
|
||||
int parts = PART_NONE;
|
||||
bool boosters_collected[100];
|
||||
vec3_t first_pos = {0,0,0};
|
||||
|
||||
void init()
|
||||
void init(const bool complete)
|
||||
{
|
||||
actor::actor_t *hero = actor::create("HERO", {16,32,8}, {8,8,12}, "test.gif", {0,32,20,32}, {-6,38});
|
||||
hero->flags = FLAG_HERO | FLAG_PUSHABLE | FLAG_GRAVITY | FLAG_ORIENTABLE | FLAG_ANIMATED;
|
||||
actor::setDirty(hero, true);
|
||||
|
||||
boost_jumps = boost_steps = boost_god = 0;
|
||||
lives = 8;
|
||||
skills = SKILL_NONE;
|
||||
parts = PART_NONE;
|
||||
for (int i=0; i<100; ++i) boosters_collected[i] = false;
|
||||
|
||||
if (complete)
|
||||
{
|
||||
lives = 8;
|
||||
skills = SKILL_NONE;
|
||||
parts = PART_NONE;
|
||||
for (int i=0; i<100; ++i) boosters_collected[i] = false;
|
||||
} else {
|
||||
hero->pos = first_pos;
|
||||
}
|
||||
}
|
||||
|
||||
int getLives()
|
||||
@@ -1469,5 +1519,11 @@ namespace actor
|
||||
if (z) hero->pos.z = *z;
|
||||
}
|
||||
|
||||
void setFirstPos()
|
||||
{
|
||||
actor_t *hero = actor::find("HERO");
|
||||
first_pos = hero->pos;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user