How would you implement a stair system

Hello everybody,

I am working on a platformer without jumping… however. I want to go to different floors using stairs like in a house. How would you manage this.
At the moment I got a StairContainer with an ArrayList and checking if the up/down button is pressed. A stair is more or less a rectangle. So I check an intersection. This is semi-cool, because I need to position the rectangle very precisely. Going up is just y -= 0.2f * delta; plus x += 0.2f * delta;

I dont really like this method ,because it has lot of lacks, and might look very strange.

I would appreciate any help. Thanks in advance.

cheers, Kronos

Instead of checking for a collision you could always just check if the player is passing through some point in a certain direction and holding/pressing up. Then ‘attach’ them to the stair, which should have its own rules for left/right motion, even if it’s just some sort of straight line, because you (probably) don’t want your character to fall through the floor if he stops holding up/down.

Hey there, thanks for your answer. How can I “attach” that guy smoothly to the stair, that it doesn’t look so mechanicly.

Can you explain what “platforming without jumping” is?

Actually there is a house with 4 floors, maybe the technical term platformer is wrong here. sorry :wink:

What kind of stair? there’s 2 kind on 2D platformer (I think the term is fit here). One is like what UpRightPath says. Other one is where you need no key press, the stair appears as terrain instead background.

Megaman stairs or castlevania stairs?

castlevania as I can see from picture research :wink:

I haven’t implemented such ladders but this might work:

  1. If a player is in a ladder tile…
  2. get player tile pixel pos by player xpos - tilepos x tilesize
  3. player ypos = tiley x tilesize - playertilepixel x slopegradient.

Sorry for the formatting as I’m using a phone to post.

I may try this logic later.

Another good thing would be to use states combined with those things above.

Thanks for the help. I think I got a good solution. I’ll post it as soon I finished it :wink: