Anyone remember Trigonometry? No? Me neither... Oh, wait, that's right, I never really took it. Well, I took Algebra and Geometry, but never a class specifically called Trigonometry. Is there such a thing? I'm sure there is. Anyways, I'm re-learning the parts of a triangle and how to find them.
Here is what I have figured out so far:
Why am I doing this? Well, I have to if I am ever going to get this game working.
Here is what I found out (after buying a $40 book to learn this. Excellent book by the way...):
In order to bounce a circle or bounce a ball off of a slope you have to bounce it off of not a slope. Yeah, let me say that again, you just basically don't bounce it off of a slope. What? Well, there is no such thing as a slope. There is flat, and then there is flat. To you it looks like a slope, but really it isn't. It's just a flat surface.
I know, I know, I'm not making sense here. Let me clarify. The only reason it looks like a slope to you, is that you are not on a level plane with it. A line is a line is a line. Tilt your head far enough and this: | will be flat and level. I'll venture to guess you only had to go about 90 degrees either way and that line became flat.
It's the same thing with flash:
- Take your angle
- Make the computer tilt it's head until you no longer have a sloped line (but rather a horizontal line)
- Do your calculation (make it bounce off of that line)
- Tell the computer to tilt it's head back
So, now I take the method I described a few days ago for finding the "slope" of the surface the ball is interacting with, and use the triangle that is formed by that interaction to apply this bounce method and I've got the main motion mechanics of my game working.
Should be easy. Hah! We'll see...