|
This thread is locked; no one can reply to it. |
1
2
|
Platformer terrain styles |
Archon
Member #4,195
January 2004
|
Quote: Which is the preferable method? I'd go with #2, but don't automatically increment the y values. Instead go left/right, if they are going down, gravity should pull them down, but if they collide with an inclined polygon, do a collision check... If the character is within the polygon, push him up to the top so he isn't anymore. |
Mark Oates
Member #1,146
March 2001
|
I have struggled with this sloped platform problem for a long time. I firmly believe that nobody will be able to provide you with the solution unless they know exactly what method needs to be used and how to implement it. here is my feeble attempt: this also might help: -- |
Epsi
Member #5,731
April 2005
|
Quote: I have struggled with this sloped platform problem for a long time. I firmly believe that nobody will be able to provide you with the solution unless they know exactly what method needs to be used and how to implement it. here is my feeble attempt: Part 6 is missing and refer to part 5 Anyway, OpenLayer handles the collision between Line and Polygon for you, so you don't have to worry about that, and you can focus on the actual implementation of your idea. ___________________________________ piccolo: "soon all new 2d alegro games will be better. after i finsh my MMRPG. my game will serve as a code reference. so you can understand and grab code from." |
Mark Oates
Member #1,146
March 2001
|
Quote: Part 6 is missing and refer to part 5
Yeah, I still haven't finished it... cause I haven't figured out how to do it! Unfortunately Openlayer doesn't calculate any reactions to a collisions. -- |
Matt Weir
Member #7,476
July 2006
|
Quote: I'll gladly take it, but I do use Dev-CPP. Who knows, maybe somebody else would want it as well. Latest OpenLayer SVN compiled for MSVC8 It's just the release build for now, I messed up the debug one and haven't got around to doing it again properly... Matt. |
Elverion
Member #6,239
September 2005
|
Quote: Anyway, OpenLayer handles the collision between Line and Polygon for you, so you don't have to worry about that, and you can focus on the actual implementation of your idea. Are you suggesting that rather than moving the player to the new coordinates that it might be better off to use OpenLayer's line method to make sure the player doesn't collide? Of course, you would still need check the player against other polygons in the area with the full collision rect that represents that player. Quote: I'd go with #2, but don't automatically increment the y values. Instead go left/right, if they are going down, gravity should pull them down, but if they collide with an inclined polygon, do a collision check... If the character is within the polygon, push him up to the top so he isn't anymore. Yes, that makes sense. Wouldn't a rough check of if a slope is too steep to climb be something along the lines of checking a point up and to the left/right that is 45° from the player? Or, I suppose, you should move the player to the left/right whatever amount, then move them up a max of speed pixels checking for collision. If they still collide after that, then it must be too steep or a wall. Oh, and thanks for the OpenLayer SVN, Matt Weir. -- |
Archon
Member #4,195
January 2004
|
Quote: Wouldn't a rough check of if a slope is too steep to climb be something along the lines of checking a point up and to the left/right that is 45° from the player? Yeah, for that, you could supply a current_position and a current_movement_vector for the map to use. You should also consider sliding effects (because it'll be a part of your algorithm) - including allowing the player to run up a slope even slightly when he is running fast. [edit] |
Epsi
Member #5,731
April 2005
|
Quote: Are you suggesting that rather than moving the player to the new coordinates that it might be better off to use OpenLayer's line method to make sure the player doesn't collide? Of course, you would still need check the player against other polygons in the area with the full collision rect that represents that player. Just check for a collision with the Collision class from OpenLayer between the player movement segment and the ground polygon. If one occurs, get the colliding segments of the ground polygon (again integrated into OL) and the point of collision. To adjust the speed of the player against the slope, it's actually quite easy. I don't remember the exact method I've used but you need to take in account the angle of the ground segment. You can do something like: newSpeed = actualSpeed - (actualSpeed * factor between -1 and 1) e.g. coming from the bottom left slope with this shape "/" is 45 deg (loose speed) ___________________________________ piccolo: "soon all new 2d alegro games will be better. after i finsh my MMRPG. my game will serve as a code reference. so you can understand and grab code from." |
Elverion
Member #6,239
September 2005
|
So, you are suggesting the 2nd method I mentioned before in combination with this? That is, not the sin/cos based movement. -- |
Archon
Member #4,195
January 2004
|
Quote: That is, not the sin/cos based movement. You'll need sin/cos somewhere. Whether it's calculated when the movement vector changes direction, or when you are updating the picture (using an integer, angle). |
|
1
2
|