XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

2D Side Scroller with inclined walking area

Last post 24/05/2009 14:15 by fritolay. 4 replies.
  • 20/05/2009 23:45

    2D Side Scroller with inclined walking area

    Hi Guys,

    I have just finished the tutorials from XNA and would like to design a platform game with a 'play' / 'walking' area similar to Castle Crashers. I am not sure what that 'area' would be classified as, or what would be necessary to build it. It almost seems like tiles, but do they stop at the center of the screen, which is followed by the background layers? Any insight would be most apreciated. Thanks all.
  • 21/05/2009 1:30 In reply to

    Re: 2D Side Scroller with inclined walking area

    You can do it all with tiles however your platforms will be very blocky, unless you have some special way to determine a tiles collision.

    One way to defeat this, is you define for every tile a line that relative to some relative origin, that will describe where the boundary the tile describes. if the player is below this line then he's collided with the ground.

    Another method is to have it flag a collision if the player is positioned over a pixel that is of a certain mask color.

    Another would be to define the shape of the level terrain with line segments and see if the player collides with this geometry.

    etc etc etc

    simply put there are a lot of ways to get boundaries which are not squares, it just takes some coding. There isn't an easy fix, I'm afraid.
  • 21/05/2009 3:55 In reply to

    Re: 2D Side Scroller with inclined walking area

    Hey Ben,

    Thanks for the reply, those are some good suggestions, I will look into trying them out to see if I can figure out how to get the look that I want. Thanks again.

    -C5
  • 21/05/2009 23:16 In reply to

    Re: 2D Side Scroller with inclined walking area

    HAven't played castle crashers, but I was watching one of the art videos by Synj posted on the dev blog and noticed a boundary layer flashed a couple times. I think they defined the level with a bunch of line segments. Not sure of how they would code that though. Probably a formula out there to tell if a point is on the left side or right side of a line segment.

    Here's the video I was talking about. There are these red lines that flash on screen around the 1:50 mark which look a lot like collision boundary information
    http://devblog.thebehemoth.com/?p=105

    Here's an idea for doing inclines. Use a list of x,y points descirbing the maximum height points at various parts of your level. Say you wanted a level 400 px long with a small 50 px tall, 50 px long pyramid in the center. Your list would have 5 entries like so: [0,0] [175,0][200,50][225,0][400,0]  What you would do is loop through this list to find the two points the player's x position is between. Then you find the slope for the line segment those points form and plug it into a simple y=mx+b formula to find out what the y position should be.

  • 24/05/2009 14:15 In reply to

    Re: 2D Side Scroller with inclined walking area

    There are some examples of this exactly as you have described with source code. You can find it by searching through the forum a little deeper.
Page 1 of 1 (5 items) Previous Next