Jump to content

Top-down RPG side-on staircases


drunkenoodle
 Share

Recommended Posts

Hello everyone,

I've been working on a little something for a while now (top-down classic rpg) using phaser. For the most part it works quite well, but there is just one thing that I can't seem to get the hang of...

 

Side-on staircases.

 

Forward facing staircases are no problem at all, but the real challenge comes when attempting to create side on stair cases like we see in the image attached.

 

I've made progress enough to get the player sprite to move up and down at a 45 degree angle, and 'almost' so that you aren't able to walk off the edges and only each end. But it's very tacky and feels hacked together, since it's using a simple check of tile properties to determine whether they are a staircase tile or not.

 

When variation comes in to it, the whole thing falls apart, considering all the different types of staircases / entrances or exits you might have. It's particularly challenging since I'm using arcade physics, I was thinking of moving to P2 so I can do a polygon check instead, thus allowing you to only travel 45 degrees while stood on that particular area.

 

Has anyone else come across this problem before? Am I perhaps missing a blatantly obvious answer (aside just not bothering at all)? :)

 

Many thanks

 

post-8429-0-32891000-1435006539.png

Link to comment
Share on other sites

Another user on this forum had succesfully made a monkey patch for slopes in Phaser's arcade physics. Maybe you could take a look at it and adjust them accordingly for this use case.

 

The link to the specific patch is located here: https://github.com/eugenioclrc/super-mean-boy/blob/master/js/Arcade.slopes.js

 

I use that for my current test project, with some slight adjustments. However, I'm not a pro at programming physics at all, so I don't think I can be of much help for your specific problem.

Link to comment
Share on other sites

Hey Mikau, thanks for your reply! I have actually already been using the script that's provided on that post (and it works great), so for that much it does actually work. The main problem seems to be entering and exiting however. I'm going to attempt at using some sort of 'floor sensor' then report back here with what I find out...

 

Cheers!

Link to comment
Share on other sites

Hello everyone,

If anyone's interested in progress I'll keep updating this topic with what I discover about side-on staircases. Code is to follow when I finally get it working nice and smoothly.

 

So far I've got a few things sorted out in regards to my problem. Basically what I decided to do was have a series of different tile types (on a collision layer) that will handle the transition between being on a stair case and not at all. What this allows for is a mode change on the player sprite.

 

For example, upon entering the staircase (either top or bottom), the mode of the player sprite is changed to 'staircase', this allows me to modify the tile callbacks to behave slightly differently. In this case, the collisions are mostly disabled and the sprite is forced to move at a 45 degree angle in either direction (to give the feel of climbing a or descending a slope). For the most part this seems to work quite well.

 

Another factor to consider is if say you have quite a wide staircase, if you're going to press the up or down keys, you might expect to be able to walk from top to bottom. Rather than be forced to still travel at a 45 degree angle. Again, I've been getting around this (so far) by disabling velocity upwards or downwards depending on if you're stood on an 'edge' tile. This has presented a few problems, as disabling y-velocity while travelling at a 45 degree angle will produce some strange results (trying to move something that you've told not to move basically).

 

Hopefully that makes sense to anyone who's interested. I'll forward some code and whatnot when it's working smoothly, as I'm still getting my head around it all...

 

Cheers!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...