Computer Science Canada Why does the line equation hate me so? |
Author: | RedRogueXIII [ Wed Aug 30, 2006 4:29 pm ] | ||
Post subject: | Why does the line equation hate me so? | ||
Here is my test platform code for a 2d sidescroller, handling slopes and such, I've gotten the main char ( a red ball ) to land on the platform then ascend a steep slope without weird bouncing, but on a slightly inverted 30* and less it gives me this weird bouncing. on straight surfaces it works fine.
Can anyone help me debug this annoying glitch? |
Author: | Cervantes [ Wed Aug 30, 2006 9:50 pm ] |
Post subject: | |
I had a similar question a while back. I don't think I ever solved it, but the code there might be of some use. Not sure. |
Author: | NikG [ Fri Sep 01, 2006 11:22 am ] | ||
Post subject: | |||
I think your problem lies in the fact that whenever the left or right arrow is pressed and there is a collision, you are added 5 to meX (and doing whatever to the other variables). Instead, you should have your move function make your ball move 5 pixels in the direction of the slope. Something along the lines of:
I think that should stop the bouncing effect. |
Author: | NikG [ Fri Sep 01, 2006 11:33 am ] | ||
Post subject: | |||
Sorry for the double post, I just thought I'd test out what I suggested:
The only problem I see with the approach is that if you have a vertical angle (say 80-90 degrees), the ball moves up/down when you press right/left, but you can probably limit this easily. |