A link to the past sliding

T

Tonydaderp

Guest
Okay. hi. I've always been wondering if it was possible and if so, how to program sliding.
What I mean is in an rpg, Such as a link to the past, if you collide to the very edge of a wall, You slide;(depending on direction, if you collided with the far left, you'd slide a little more to the left, etc)
I think this enhances gameplay to be a little smoother, as if your collision mask is a tiny bit bigger than the actual sprite, and you collide just enough so that you look like your not even colliding, if you know what I mean.
Can anyone help? The code for sliding of walls... like in Zelda : a link to the past?
plz help.
 
M

Meowmere

Guest
like pushing objects? or where you'd have a push animation?
but yes, whatever it is, it can be made in GM:S which sounds relatively simple. I never played lttp (it's so ugly :| ) I played Minish Cap though.
 

Phil Strahl

Member
I'm re-playing A Link to the Past right now on my 3DS, but I don't think I quite get what you're referring to. Got an example, screenshot, GIF, video, anything?
 
He means the "smooth-collision" effect where you would normally run into the last few pixels of a wall that don't look like they would stop you, but instead you sort of shift around the collision and are now hugging the wall.
You could probably accomplish this by using place_free upon colliding with a wall.
Pseudo-code:
Code:
if (COLLISION WITH OBJECT) {

    if (DIRECTION == RIGHT) {
        //we collided with a wall on the right, so check up and down for empty locations
        if (place_free(x, y-DISTANCE, OBJ_COLLIDE)) {
            y -= DISTANCE; //move the character up to avoid the wall
        } else if (place_free(x, y+DISTANCE, OBJ_COLLIDE)) {
             y += DISTANCE;
        }
    }

}
Obviously this won't work in its current state, but you should get an idea about how to go about doing it
 
A

Azure Spectre

Guest
I found an article last year talking about this exact thing. It's hard to notice it while playing LttP, it feels so natural. I made a couple movement engines with this feature, tons of fun to build. :D
 
T

Tonydaderp

Guest
He means the "smooth-collision" effect where you would normally run into the last few pixels of a wall that don't look like they would stop you, but instead you sort of shift around the collision and are now hugging the wall.
You could probably accomplish this by using place_free upon colliding with a wall.
Pseudo-code:
Code:
if (COLLISION WITH OBJECT) {

    if (DIRECTION == RIGHT) {
        //we collided with a wall on the right, so check up and down for empty locations
        if (place_free(x, y-DISTANCE, OBJ_COLLIDE)) {
            y -= DISTANCE; //move the character up to avoid the wall
        } else if (place_free(x, y+DISTANCE, OBJ_COLLIDE)) {
             y += DISTANCE;
        }
    }

}
Obviously this won't work in its current state, but you should get an idea about how to go about doing it
Thanks! Really big help! you rock!
 
T

Tonydaderp

Guest
He means the "smooth-collision" effect where you would normally run into the last few pixels of a wall that don't look like they would stop you, but instead you sort of shift around the collision and are now hugging the wall.
You could probably accomplish this by using place_free upon colliding with a wall.
Pseudo-code:
Code:
if (COLLISION WITH OBJECT) {

    if (DIRECTION == RIGHT) {
        //we collided with a wall on the right, so check up and down for empty locations
        if (place_free(x, y-DISTANCE, OBJ_COLLIDE)) {
            y -= DISTANCE; //move the character up to avoid the wall
        } else if (place_free(x, y+DISTANCE, OBJ_COLLIDE)) {
             y += DISTANCE;
        }
    }

}
Obviously this won't work in its current state, but you should get an idea about how to go about doing it

Thanks, but there is one thing. I have tested it out and it works GODly, but the player does not move depending if the left or right is free. it is actually if the player collides with(example)the top left quadrant, he moves left by like 2 pixels. Else
if he collides withthe top right quadrant, he moves right by like 2 pixels.
This might sound easy, but I do know that you cant specify which quadrant you collide with.

I could just have 4 objects for each quadrants, but I was wondering if it was possible to do something about it without making more objects. thanks! Also, don't worry about if you collide in the center while touching two quadrants, because in the original zelda 3 that also happens if your in the center.

Wait! I have an idea.. can you maybe do a grid check... to separate into quadrants
...
 
Last edited by a moderator:
T

Tonydaderp

Guest
Thanks, but there is one thing. I have tested it out and it works GODly, but the player does not move depending if the left or right is free. it is actually if the player collides with(example)the top left quadrant, he moves left by like 2 pixels. Else
if he collides withthe top right quadrant, he moves right by like 2 pixels.
This might sound easy, but I do know that you cant specify which quadrant you collide with.

I could just have 4 objects for each quadrants, but I was wondering if it was possible to do something about it without making more objects. thanks!
But if you cant figure out something, thanks a lot anyways!;)
 
Top