- Treballant en el push, els reactius i la gravetat :P
This commit is contained in:
@@ -40,6 +40,7 @@ namespace actor
|
||||
act->prev = act->next = nullptr;
|
||||
act->anim_wait = act->anim_wait_count = 0;
|
||||
act->anim_frame=0;
|
||||
act->react_mask = act->react_push = 0;
|
||||
return act;
|
||||
}
|
||||
|
||||
@@ -299,7 +300,7 @@ namespace actor
|
||||
act->mov_push = act->mov_push==PUSH_YP ? PUSH_YN : PUSH_YP;
|
||||
break;
|
||||
case MOV_Z:
|
||||
act->mov_push = act->mov_push==PUSH_ZP ? PUSH_ZN : PUSH_ZP;
|
||||
act->mov_push = act->mov_push==PUSH_ZN ? PUSH_ZP : PUSH_ZN;
|
||||
break;
|
||||
case MOV_CW:
|
||||
switch (act->mov_push)
|
||||
@@ -335,8 +336,28 @@ namespace actor
|
||||
act->orient = act->mov_push;
|
||||
}
|
||||
|
||||
void updateReactive(actor_t *act)
|
||||
{
|
||||
if (act->push & act->react_mask)
|
||||
{
|
||||
actor_t *other = nullptr;
|
||||
|
||||
if (act->push == PUSH_XP) { act->pos.x-=2; other = get_collision(act); act->pos.x+=2; }
|
||||
else if (act->push == PUSH_XN) { act->pos.x++; other = get_collision(act); act->pos.x--; }
|
||||
else if (act->push == PUSH_YP) { act->pos.y--; other = get_collision(act); act->pos.y++; }
|
||||
else if (act->push == PUSH_YN) { act->pos.y++; other = get_collision(act); act->pos.y--; }
|
||||
else if (act->push == PUSH_ZN) { act->pos.z++; other = get_collision(act); act->pos.z--; }
|
||||
|
||||
if (other) {
|
||||
other->push |= act->react_push;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void updatePushable(actor_t *act)
|
||||
{
|
||||
if (act->flags & FLAG_REACTIVE) { updateReactive(act); return; }
|
||||
|
||||
vec3_t min = room::getMin();
|
||||
vec3_t max = room::getMax();
|
||||
|
||||
@@ -353,9 +374,12 @@ namespace actor
|
||||
actor_t *now = act;
|
||||
do {
|
||||
actor::actor_t *other = actor::any_above_me(now);
|
||||
now->pos.z++;
|
||||
//if (other) other->pos.z++;
|
||||
if (!other || (other->flags & FLAG_PUSHABLE)) now->pos.z++;
|
||||
now = other;
|
||||
if (now && !(now->flags & FLAG_PUSHABLE)) {
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
now = nullptr;
|
||||
}
|
||||
} while (now);
|
||||
|
||||
actor::setDirty(act);
|
||||
@@ -367,7 +391,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 && other->flags & FLAG_PUSHABLE) other->push |= PUSH_XN;
|
||||
if (other && other->flags & FLAG_SENSIBLE) other->push |= PUSH_XN;
|
||||
act->pos.x++;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -397,7 +421,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || (act->pos.x>max.x && ( !(room::getDoors()&DOOR_XP) || (act->pos.y!=28) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_XP;
|
||||
if (other && other->flags & FLAG_SENSIBLE) other->push |= PUSH_XP;
|
||||
act->pos.x--;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -427,7 +451,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(XN)*4) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_YN;
|
||||
if (other && other->flags & FLAG_SENSIBLE) other->push |= PUSH_YN;
|
||||
act->pos.y++;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -457,7 +481,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || ( act->pos.y>max.y && ( !(room::getDoors()&DOOR_YP) || (act->pos.x!=28) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_YP;
|
||||
if (other && other->flags & FLAG_SENSIBLE) other->push |= PUSH_YP;
|
||||
act->pos.y--;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -487,7 +511,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || act->pos.z<0 || act->pos.x>max.x || act->pos.x<min.x || act->pos.y>max.y || act->pos.y<min.y)
|
||||
{
|
||||
//if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_ZN;
|
||||
if (other && other->flags & FLAG_REACTIVE) other->push |= PUSH_ZN;
|
||||
act->pos.z++;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -499,21 +523,6 @@ namespace actor
|
||||
|
||||
}
|
||||
|
||||
void updateReactive(actor_t *act)
|
||||
{
|
||||
if (act->push & act->react_mask)
|
||||
{
|
||||
actor_t *other = nullptr;
|
||||
|
||||
if (act->push == PUSH_XP) { act->pos.x--; other = get_collision(act); act->pos.x++; }
|
||||
else if (act->push == PUSH_XN) { act->pos.x++; other = get_collision(act); act->pos.x--; }
|
||||
else if (act->push == PUSH_YP) { act->pos.y--; other = get_collision(act); act->pos.y++; }
|
||||
else if (act->push == PUSH_YN) { act->pos.y++; other = get_collision(act); act->pos.y--; }
|
||||
|
||||
if (other) other->push |= act->react_push;
|
||||
}
|
||||
}
|
||||
|
||||
void updateGravity(actor_t *act)
|
||||
{
|
||||
if (act->pos.z == 0) return;
|
||||
@@ -526,6 +535,11 @@ namespace actor
|
||||
actor_t *below = any_below_me(act);
|
||||
if (below)
|
||||
{
|
||||
if (below->flags & FLAG_REACTIVE) {
|
||||
below->push |= PUSH_ZN;
|
||||
updateReactive(below);
|
||||
if (act->push) updatePushable(act);
|
||||
}
|
||||
act->below = below;
|
||||
below->above = act;
|
||||
return;
|
||||
@@ -553,7 +567,7 @@ namespace actor
|
||||
//if (act->flags & FLAG_PUSHABLE)
|
||||
updatePushable(act);
|
||||
if (act->flags & FLAG_GRAVITY) updateGravity(act);
|
||||
if (act->flags & FLAG_REACTIVE) updateReactive(act);
|
||||
//if (act->flags & FLAG_REACTIVE) updateReactive(act);
|
||||
|
||||
act->push = PUSH_NONE;
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#define FLAG_GRAVITY 128 // Li afecta la gravetat
|
||||
#define FLAG_NOEDITOR 256 // No es seleccionable a l'editor (son les portes)
|
||||
|
||||
#define FLAG_SENSIBLE 6 // PUSHABLE or REACTIVE
|
||||
|
||||
// Direcció de espenta
|
||||
#define PUSH_NONE 0
|
||||
#define PUSH_XP 1
|
||||
|
||||
@@ -68,11 +68,11 @@ void game::init()
|
||||
buffer[len-1]=0;
|
||||
gifs.push_back(std::string(buffer));
|
||||
}
|
||||
//actor::actor_t *hero = actor::create("HERO", {16,32,8}, {8,8,12}, "test.gif", {0,32,20,32}, {-6,38});
|
||||
actor::actor_t *hero = actor::create("HERO", {16,32,8}, {8,8,12}, "test.gif", {0,32,20,32}, {-6,38});
|
||||
|
||||
//actor::actor_t *hero = actor::create("HEROHEROHEROHER", {16,32,8}, {8,8,12}, "abad.gif", {0,0,20,35}, {-6,32});
|
||||
//hero->flags = FLAG_HERO | FLAG_PUSHABLE | FLAG_GRAVITY | FLAG_ORIENTABLE | FLAG_ANIMATED;
|
||||
//actor::setDirty(hero, true);
|
||||
hero->flags = FLAG_HERO | FLAG_PUSHABLE | FLAG_GRAVITY | FLAG_ORIENTABLE | FLAG_ANIMATED;
|
||||
actor::setDirty(hero, true);
|
||||
|
||||
actor::clear();
|
||||
|
||||
@@ -139,6 +139,24 @@ void btn_small(const int x, const int y, int &var, int min, int max, bool restrt
|
||||
}
|
||||
}
|
||||
|
||||
void btn_check(const int x, const int y, const char* label, uint8_t &flags, const uint8_t value)
|
||||
{
|
||||
int result=0;
|
||||
if (flags & value) {
|
||||
result=ui::check(label, x, y, 12, 11, true);
|
||||
} else {
|
||||
result=ui::check(label, x, y, 12, 11, false);
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
if (flags & value) {
|
||||
flags = flags & ~value;
|
||||
} else {
|
||||
flags = flags | value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void btn_check(const int x, const int y, const char* label, uint16_t &flags, const uint16_t value)
|
||||
{
|
||||
int result=0;
|
||||
@@ -251,10 +269,10 @@ bool game::loop()
|
||||
if (input::keyDown(SDL_SCANCODE_ESCAPE)) return false;
|
||||
|
||||
// WHILE EDITING...
|
||||
editor_move_selected();
|
||||
actor::updateEditor(actor::getFirst());
|
||||
//editor_move_selected();
|
||||
//actor::updateEditor(actor::getFirst());
|
||||
|
||||
//actor::update(actor::getFirst());
|
||||
actor::update(actor::getFirst());
|
||||
|
||||
actor::reorder();
|
||||
|
||||
@@ -351,7 +369,7 @@ bool game::loop()
|
||||
act = actor::getSelected();
|
||||
if (act)
|
||||
{
|
||||
draw::setViewport(420, 110, 100, 240);
|
||||
draw::setViewport(420, 90, 100, 240);
|
||||
|
||||
btn_txt("NAME:", 2, 0, act->name);
|
||||
if (btn_opt2("BMP:", 2, 10, act->bmp, gifs)) {
|
||||
@@ -388,7 +406,7 @@ bool game::loop()
|
||||
btn_check(50, 74, "DEAD", act->flags, FLAG_DEADLY);
|
||||
btn_check(74, 74, "GRAV", act->flags, FLAG_GRAVITY);
|
||||
|
||||
btn_opt("ORIENT", 2, 86, act->orient, {PUSH_NONE, PUSH_XP, PUSH_XN, PUSH_YP, PUSH_YN}, {"NONE", "XP", "XN", "YP", "YN"});
|
||||
btn_opt("ORIENT", 2, 86, act->orient, {PUSH_NONE, PUSH_XP, PUSH_XN, PUSH_YP, PUSH_YN, PUSH_ZP, PUSH_ZN}, {"NONE", "XP", "XN", "YP", "YN", "ZP", "ZN"});
|
||||
btn_opt("MOVEMNT", 2, 96, act->movement, {MOV_NONE, MOV_X, MOV_Y, MOV_Z, MOV_CW, MOV_CCW, MOV_RAND, MOV_HUNT}, {"NONE", "X", "Y", "Z", "CW", "CCW", "RAND", "HUNT"});
|
||||
btn_opt("ANIMCYC", 2, 106, act->anim_cycle, {0, 1}, {"0 1 0 2", "0 1 2 3"});
|
||||
|
||||
@@ -396,6 +414,22 @@ bool game::loop()
|
||||
ui::label("ANMSPED", 2, 116, 32, 11);
|
||||
btn_small(81, 116, act->anim_wait, 0, 10);
|
||||
|
||||
ui::label("RMASK", 2, 128, 24, 11);
|
||||
btn_check(24+2, 128, "XP", act->react_mask, PUSH_XP);
|
||||
btn_check(24+14, 128, "XN", act->react_mask, PUSH_XN);
|
||||
btn_check(24+26, 128, "YP", act->react_mask, PUSH_YP);
|
||||
btn_check(24+38, 128, "YN", act->react_mask, PUSH_YN);
|
||||
btn_check(24+50, 128, "ZP", act->react_mask, PUSH_ZP);
|
||||
btn_check(24+62, 128, "ZN", act->react_mask, PUSH_ZN);
|
||||
|
||||
ui::label("RPUSH", 2, 140, 24, 11);
|
||||
btn_check(24+2, 140, "XP", act->react_push, PUSH_XP);
|
||||
btn_check(24+14, 140, "XN", act->react_push, PUSH_XN);
|
||||
btn_check(24+26, 140, "YP", act->react_push, PUSH_YP);
|
||||
btn_check(24+38, 140, "YN", act->react_push, PUSH_YN);
|
||||
btn_check(24+50, 140, "ZP", act->react_push, PUSH_ZP);
|
||||
btn_check(24+62, 140, "ZN", act->react_push, PUSH_ZN);
|
||||
|
||||
/*
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user