- Les portes nomes deixen passar en la Z correcta

- Les vores de les portes espenten cap a la porta
This commit is contained in:
2023-06-06 18:05:42 +02:00
parent 845772ed16
commit 4986e76864
4 changed files with 69 additions and 14 deletions

View File

@@ -168,8 +168,16 @@ namespace actor
act->orient=PUSH_XN; act->orient=PUSH_XN;
if ( (act->pos.x>min.x && act->pos.y>=min.y && act->pos.y<=max.y) || ( (room::getDoors()&DOOR_XN) && (act->pos.y>=24) && (act->pos.y<=32) ) ) if ( (act->pos.x>min.x && act->pos.y>=min.y && act->pos.y<=max.y) || ( (room::getDoors()&DOOR_XN) && (act->pos.y>=24) && (act->pos.y<=32) ) )
{ {
act->push |= PUSH_XN;
moving = true; moving = true;
if ( (act->pos.x<=min.x) && (act->pos.z==room::getDoor(XN)*4) && (room::getDoors()&DOOR_XN) ) {
if (act->pos.y<28)
act->push |= PUSH_YP;
else if (act->pos.y>28)
act->push |= PUSH_YN;
else
act->push |= PUSH_XN;
} else
act->push |= PUSH_XN;
} }
} }
if ( input::keyDown(SDL_SCANCODE_RIGHT) ) if ( input::keyDown(SDL_SCANCODE_RIGHT) )
@@ -177,8 +185,16 @@ namespace actor
act->orient=PUSH_XP; act->orient=PUSH_XP;
if ( (act->pos.x<max.x && act->pos.y>=min.y && act->pos.y<=max.y) || ( (room::getDoors()&DOOR_XP) && (act->pos.y>=24) && (act->pos.y<=32) ) ) if ( (act->pos.x<max.x && act->pos.y>=min.y && act->pos.y<=max.y) || ( (room::getDoors()&DOOR_XP) && (act->pos.y>=24) && (act->pos.y<=32) ) )
{ {
act->push |= PUSH_XP;
moving = true; moving = true;
if ( (act->pos.x>=max.x) && (act->pos.z==room::getDoor(XP)*4) && (room::getDoors()&DOOR_XP) ) {
if (act->pos.y<28)
act->push |= PUSH_YP;
else if (act->pos.y>28)
act->push |= PUSH_YN;
else
act->push |= PUSH_XP;
} else
act->push |= PUSH_XP;
} }
} }
if ( input::keyDown(SDL_SCANCODE_UP) ) if ( input::keyDown(SDL_SCANCODE_UP) )
@@ -186,8 +202,16 @@ namespace actor
act->orient=PUSH_YN; act->orient=PUSH_YN;
if ( (act->pos.y>min.y && act->pos.x>=min.x && act->pos.x<=max.x) || ( (room::getDoors()&DOOR_YN) && (act->pos.x>=24) && (act->pos.x<=32) ) ) if ( (act->pos.y>min.y && act->pos.x>=min.x && act->pos.x<=max.x) || ( (room::getDoors()&DOOR_YN) && (act->pos.x>=24) && (act->pos.x<=32) ) )
{ {
act->push |= PUSH_YN;
moving = true; moving = true;
if ( (act->pos.y<=min.y) && (act->pos.z==room::getDoor(YN)*4) && (room::getDoors()&DOOR_YN) ) {
if (act->pos.x<28)
act->push |= PUSH_XP;
else if (act->pos.x>28)
act->push |= PUSH_XN;
else
act->push |= PUSH_YN;
} else
act->push |= PUSH_YN;
} }
} }
if ( input::keyDown(SDL_SCANCODE_DOWN) ) if ( input::keyDown(SDL_SCANCODE_DOWN) )
@@ -195,8 +219,16 @@ namespace actor
act->orient=PUSH_YP; act->orient=PUSH_YP;
if ( (act->pos.y<max.y && act->pos.x>=min.x && act->pos.x<=max.x) || ( (room::getDoors()&DOOR_YP) && (act->pos.x>=24) && (act->pos.x<=32) ) ) if ( (act->pos.y<max.y && act->pos.x>=min.x && act->pos.x<=max.x) || ( (room::getDoors()&DOOR_YP) && (act->pos.x>=24) && (act->pos.x<=32) ) )
{ {
act->push |= PUSH_YP;
moving = true; moving = true;
if ( (act->pos.y>=max.y) && (act->pos.z==room::getDoor(YP)*4) && (room::getDoors()&DOOR_YP) ) {
if (act->pos.x<28)
act->push |= PUSH_XP;
else if (act->pos.x>28)
act->push |= PUSH_XN;
else
act->push |= PUSH_YP;
} else
act->push |= PUSH_YP;
} }
} }
if ( input::keyDown(SDL_SCANCODE_SPACE) && act->pos.y<=max.y && act->pos.y>=min.y && act->pos.x<=max.x && act->pos.x>=min.x && act->react_mask==0 && (act->pos.z==0 || act->below)) if ( input::keyDown(SDL_SCANCODE_SPACE) && act->pos.y<=max.y && act->pos.y>=min.y && act->pos.x<=max.x && act->pos.x>=min.x && act->react_mask==0 && (act->pos.z==0 || act->below))
@@ -215,6 +247,8 @@ namespace actor
if (act->react_mask) if (act->react_mask)
{ {
if (act->pos.x>max.x || act->pos.x<min.x || act->pos.y>max.y || act->pos.y<min.y) act->react_push=8;
if (act->react_push<8) if (act->react_push<8)
{ {
act->pos.z++; act->pos.z++;
@@ -294,6 +328,9 @@ namespace actor
vec3_t min = room::getMin(); vec3_t min = room::getMin();
vec3_t max = room::getMax(); 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_ZP) { if (act->push & PUSH_ZP) {
if (act->pos.z>=max.z) if (act->pos.z>=max.z)
{ {
@@ -316,7 +353,7 @@ namespace actor
if (act->push & PUSH_XN) { if (act->push & PUSH_XN) {
act->pos.x--; act->pos.x--;
actor::actor_t *other = actor::get_collision(act); actor::actor_t *other = actor::get_collision(act);
if (other || ( act->pos.x<min.x && ( !(room::getDoors()&DOOR_XN) || (act->pos.y!=28) || !(act->flags&FLAG_HERO) ) )) 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_PUSHABLE) other->push |= PUSH_XN;
act->pos.x++; act->pos.x++;
@@ -370,7 +407,7 @@ namespace actor
if (act->push & PUSH_YN) { if (act->push & PUSH_YN) {
act->pos.y--; act->pos.y--;
actor::actor_t *other = actor::get_collision(act); actor::actor_t *other = actor::get_collision(act);
if (other || ( act->pos.y<min.y && ( !(room::getDoors()&DOOR_YN) || (act->pos.x!=28) || !(act->flags&FLAG_HERO) ) )) 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_PUSHABLE) other->push |= PUSH_YN;
act->pos.y++; act->pos.y++;
@@ -424,7 +461,7 @@ namespace actor
if (act->push & PUSH_ZN) { if (act->push & PUSH_ZN) {
act->pos.z--; act->pos.z--;
actor::actor_t *other = actor::get_collision(act); actor::actor_t *other = actor::get_collision(act);
if (act->pos.z<0 || other) 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_PUSHABLE) other->push |= PUSH_ZN;
act->pos.z++; act->pos.z++;
@@ -469,6 +506,10 @@ namespace actor
below->above = act; below->above = act;
return; return;
} }
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;
act->pos.z--; act->pos.z--;
} }

View File

@@ -8,23 +8,25 @@
draw::surface *surf; draw::surface *surf;
actor::actor_t *box; actor::actor_t *box;
int room_w = 0; int room_w = 2;
int room_h = 0; int room_h = 2;
int room_xp = 0; int room_xp = -1;
int room_xn = 0; int room_xn = -1;
int room_yp = 0; int room_yp = -1;
int room_yn = 0; int room_yn = -1;
void restart() void restart()
{ {
actor::clear(); actor::clear();
room::load(room_w, room_h, room_xp, room_xn, room_yp, room_yn); room::load(room_w, room_h, room_xp, room_xn, room_yp, room_yn);
/*
box = actor::create("ASCENSOR",{16,32,0}, {8,8,4}, {64,0,32,24}, {0,24}); box = actor::create("ASCENSOR",{16,32,0}, {8,8,4}, {64,0,32,24}, {0,24});
box->flags = FLAG_MOVING; box->flags = FLAG_MOVING;
box->movement = MOV_Z; box->movement = MOV_Z;
box->mov_push = PUSH_ZP; box->mov_push = PUSH_ZP;
actor::setDirty(box, true); actor::setDirty(box, true);
*/
box = actor::create("BOX", {32,32,16}, {8,8,8}, {32,0,32,32}, {0,32}); 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;
@@ -75,7 +77,7 @@ void btn(const char* label, const int x, const int y, int &var, int min, int max
{ {
char buffer[100]; char buffer[100];
int result=0; int result=0;
draw::print("ROOM WIDTH:", x, y+3, 15, 0); draw::print(label, x, y+3, 15, 0);
result=ui::button(SDL_itoa(var, buffer, 10), x+50, y, 28, 11); result=ui::button(SDL_itoa(var, buffer, 10), x+50, y, 28, 11);
if (result) if (result)
{ {

View File

@@ -162,4 +162,10 @@ namespace room
{ {
return doors; return doors;
} }
uint8_t getDoor(const int d)
{
return door_height[d];
}
} }

View File

@@ -6,6 +6,11 @@
#define DOOR_YP 4 #define DOOR_YP 4
#define DOOR_YN 8 #define DOOR_YN 8
#define XP 0
#define XN 1
#define YP 2
#define YN 3
namespace room namespace room
{ {
void load(int x, int y, int8_t xp, int8_t xn, int8_t yp, int8_t yn); void load(int x, int y, int8_t xp, int8_t xn, int8_t yp, int8_t yn);
@@ -16,4 +21,5 @@ namespace room
vec3_t getMin(); vec3_t getMin();
vec3_t getMax(); vec3_t getMax();
uint8_t getDoors(); uint8_t getDoors();
uint8_t getDoor(const int d);
} }