Slopes/stairs in side-scrolling, keyboard-controlled game

Started by Lewis, Thu 23/05/2013 07:29:54

Previous topic - Next topic

Lewis

Hello! Is this a beginners' question still? I'm not sure. I never know what sort of level I'm at.

ANYWAY.

We're working on a side-scrolling game. Movement is entirely keyboard-controlled, with the mouse only used for interacting with the world. Movement is bound to A and D - there's no jumping or crouching - and characters move along 1px-thin walkable areas.

Problem is, we'd like to include slopes and stairs in the game, but I can't wrap my head around how to do this. Obviously, when you get to this sort of obstacle, I need the player character to move diagonally up and to the right, even though the player is only pressing the 'move right' key.

Any pointers on how to achieve this would be super-appreciated, as it would be kinda bland to have a side-scrolling game where everything was just on the same plane. Cheers!
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

Phemar

If there are no double pixels on your slope's walkable area, the character won't be able to walk up it.

Lewis

I've tried it with multiple pixels as well, the problem is that the character gets 'stuck' as the 'move right' button literally does that - moves the player character ++ along the x axis.

What I'm hoping we can do is find a way that, when the player reaches a slope, continuing to press 'move right' moves the character up the slope accordingly.
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

Crimson Wizard

I think, first you need a way to define stairs e.g. by drawing a region over it and tagging it with certain custom property which marks it as stairs (like "IsStairs" = true) and where it goes (like "Direction" = 1 for rising to left and = 2 for rising to right).

Then check if character is at region with this property. If he/she is, then adjust movement direction when he is told to move.

Lewis

Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

Crimson Wizard

#5
Oh my, the regions do not have custom properties! Only hotspots do.

What's a shame, it would be better if walkable areas had ones, in which case you won't need extra regions over them... an idea for the next ags version perhaps. ;)


EDIT: Also, you may set up an array in the script, which stores the IDs of walkable areas per room and corresponding properties.

Calin Leafshade

Alternatively you could do it like a platformer whereby you move the player down until it hits a walkable area everytime you move the player forwards so they are always resting on a walkable area.

Crimson Wizard

Quote from: Calin Leafshade on Thu 23/05/2013 10:24:36
Alternatively you could do it like a platformer whereby you move the player down until it hits a walkable area everytime you move the player forwards so they are always resting on a walkable area.
How that will work for rising stairs?

Khris

I'd probably go the vector route.

Say you have this:
________
        ---
           ---
              ---________________

The y position is going to be something like
if (x < 100) y = 130
else if (x < 150) y = x + 20   // slope
else y = 170

Movement changes the x coordinate, the according y is calculated, and the character is positioned and animated by hand.

Calin Leafshade

Quote from: Crimson Wizard on Thu 23/05/2013 10:27:25
How that will work for rising stairs?

If the player is already on a walkable area you move the player up until they are no longer on it and then move them 1 pixel down. Essentially you always make sure that the player is on the top of the walkable area, using them like colliders rather than regions.

@Khris

I think your method is more difficult to generalise than mine.

Khris

Yep, I'd maybe actually do it your way, depending on the circumstances.
I just like math :)

SMF spam blocked by CleanTalk