-Treballant en les portes

This commit is contained in:
2023-06-02 12:15:39 +02:00
parent e710069aec
commit 234f6dc287
4 changed files with 52 additions and 17 deletions

View File

@@ -164,7 +164,7 @@ namespace actor
if ( input::keyDown(SDL_SCANCODE_LEFT) )
{
act->orient=PUSH_XN;
if (act->pos.x>min.x)
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;
@@ -173,7 +173,7 @@ namespace actor
if ( input::keyDown(SDL_SCANCODE_RIGHT) )
{
act->orient=PUSH_XP;
if (act->pos.x<max.x)
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;
@@ -182,7 +182,7 @@ namespace actor
if ( input::keyDown(SDL_SCANCODE_UP) )
{
act->orient=PUSH_YN;
if (act->pos.y>min.y)
if ( (act->pos.y>min.y && act->pos.x>=min.y && act->pos.x<=max.x) || ( (room::getDoors()&DOOR_YN) && (act->pos.x>=24) && (act->pos.x<=32) ) )
{
act->push |= PUSH_YN;
moving = true;
@@ -191,7 +191,7 @@ namespace actor
if ( input::keyDown(SDL_SCANCODE_DOWN) )
{
act->orient=PUSH_YP;
if (act->pos.y<max.y)
if ( (act->pos.y<max.y && act->pos.x>=min.y && act->pos.x<=max.x) || ( (room::getDoors()&DOOR_YP) && (act->pos.x>=24) && (act->pos.x<=32) ) )
{
act->push |= PUSH_YP;
moving = true;
@@ -314,7 +314,7 @@ namespace actor
if (act->push & PUSH_XN) {
act->pos.x--;
actor::actor_t *other = actor::get_collision(act);
if (act->pos.x<min.x || other)
if (other || ( act->pos.x<min.x && ( !(room::getDoors()&DOOR_XN) || (act->pos.y!=28) ) ))
{
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_XN;
act->pos.x++;
@@ -332,6 +332,8 @@ namespace actor
act->above->push = 0;
}
}
if (act->pos.x<min.x-4) act->pos.x = max.x;
actor::setDirty(act);
}
}
@@ -339,7 +341,7 @@ namespace actor
if (act->push & PUSH_XP) {
act->pos.x++;
actor::actor_t *other = actor::get_collision(act);
if (act->pos.x>max.x || other)
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;
act->pos.x--;
@@ -357,6 +359,8 @@ namespace actor
act->above->push = 0;
}
}
if (act->pos.x>max.x+4) act->pos.x = min.x;
actor::setDirty(act);
}
}
@@ -364,7 +368,7 @@ namespace actor
if (act->push & PUSH_YN) {
act->pos.y--;
actor::actor_t *other = actor::get_collision(act);
if (act->pos.y<min.y || other)
if (other || ( act->pos.y<min.y && ( !(room::getDoors()&DOOR_YN) || (act->pos.x!=28) ) ))
{
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_YN;
act->pos.y++;
@@ -382,6 +386,8 @@ namespace actor
act->above->push = 0;
}
}
if (act->pos.y<min.y-4) act->pos.y = max.y;
actor::setDirty(act);
}
}
@@ -389,7 +395,7 @@ namespace actor
if (act->push & PUSH_YP) {
act->pos.y++;
actor::actor_t *other = actor::get_collision(act);
if (act->pos.y>max.y ||other)
if (other || ( act->pos.y>max.y && ( !(room::getDoors()&DOOR_YP) || (act->pos.x!=28) ) ))
{
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_YP;
act->pos.y--;
@@ -407,6 +413,8 @@ namespace actor
act->above->push = 0;
}
}
if (act->pos.y>max.y+4) act->pos.y = min.y;
actor::setDirty(act);
}
}
@@ -481,15 +489,20 @@ namespace actor
void print(int x, int y, int num)
{
int digits=0;
bool sign = num < 0;
num = SDL_abs(num);
int n = num;
while (n>0) {n=n/10;digits++;}
if (sign) digits++;
x=x+digits*4;
if (num==0) draw::draw(x+4,y,5,7,0,120);
while (num>0)
{
draw::draw(x,y,5,7,(num%10)*5,120);
num=num/10;
x=x-4;
}
if (sign) draw::draw(x,y,5,7,50,120);
}
//int order=0;
@@ -507,10 +520,10 @@ namespace actor
const int ao = (act->flags & FLAG_ANIMATED) ? anims[act->anim_cycle][anim_frame]*act->bmp_rect.w : 0;
draw::draw(x, y, act->bmp_rect.w, act->bmp_rect.h, act->bmp_rect.x+ao, act->bmp_rect.y+oo, flip);
//print(x+5,y,act->pos.x);
//print(x+5,y+6,act->pos.y);
print(x+5,y,act->pos.x);
print(x+5,y+6,act->pos.y);
//print(x+5,y+12,order);
print(x+5,y,act->flags);
//print(x+5,y,act->flags);
if (draw_all && act->next) draw(act->next);
}