At 4/4/09 10:21 PM, liaaaam wrote:
At 4/4/09 10:03 PM, Nano256 wrote:
Didn't read that post, but I provided a solution that you seem to think is not possible.
Your solution was to make the _y value of the ball so that the ball is "exactly touching the ground when the hittest occurs" - think about how little sense that makes.
You could not be more wrong, sorry,
http://spamtheweb.com/ul/upload/040409/7 0307_BallBouce.php
I just added one line of code to the original and came up with that.
And my code for quick viewing:
var defGravity = 6;
var gravity = defGravity;
var gravPlus = 1;
var speed = 4;
onEnterFrame = function()
{
gravity += gravPlus;
ball._y += gravity;
if(ball.hitTest(ground))
{
gravPlus += .1;
gravity = -gravity;
ball._y = ground._y-ball._height/2;
}
if(Key.isDown(Key.LEFT))
{
ball._x-=speed;
ball.design._rotation-=10;
}
if(Key.isDown(Key.RIGHT)){
ball._x+=speed;
ball.design._rotation+=10;
}
}
Here's the fla:
http://spamtheweb.com/ul/upload/040409/7 0352_BallBouce.fla
Also take into account the fact that when the hittest is true the y speed is decreased by .1 or whatever it was,
Wrong. The y speed is actually the negative of whatever it was (so if it was 15, its now -15). We have already added to the ball's y coordinate before the collision is checked.
We are actually adding .1 to the gravity, which just makes the ball faster after ever bounce.
so assuming that you mean the ball is only just touching the ground in a manor that would mean it doesn't touch the ground at the next frame thus stopping the constant change of direction that is the problem, you would need to account for this regular change of speed. How are you going to calculate the exact location that would allow for this? Good luck with that.
Mmmm... Problem solved.
Also, there is no point making an engine thatjavascript:BBSPost.Save(); only works in very specific circumstances, it's much better to have code that works.. properly.
The code works like a charm, it just needed a minor change, and there could even be more refinement to it.