Chance test 2

I need help in making the ball bounce on the pins instead of bouncing off of them and it looks like that there is no gravity.

My question is how do I make gravity for my ball.
The AY acceleration doesn’t work.

Updated test

Ah, yes, the BounceOnWall flag is a little too bouncy for something like this. It’s easier to use the ay if you do your own collision handling for bouncing. I played around for a while and came up with something that works pretty well.

First of all, let’s use “on sprite hits wall” instead of “on sprite overlaps tile”. Sprites never overlap with walls, so the overlap event will never fire (I noticed that it was in the code you shared).

To get bouncing behavior, we want to reverse vy when we hit the wall from the bottom and reverse vx when hitting a wall on the right or left. We can do the reverse by simply multiplying the velocity by -1. This code is almost exactly the same as using BounceOnWall:

and here’s what it looks like in the game:

Way too bouncy! The ball never even makes it to the bottom. To make it less bouncy, we need to lower the velocity at the same time as when we reverse it. To do that, we can change -1 to be -0.7 like this:

And here’s what that looks like in the game:

Now it gets to the bottom, but it’s also pretty boring. It’s missing the random element that you get in real world games. To mimic that behavior, let’s change vx by a random amount and give it a chance to reverse. Here’s that code:

And here’s what that looks like in the game:

Definitely more random! The ball often goes flying though and it looks a little too chaotic. In the real world, the ball will only go flying if the speed is high enough. So, if we take the same changes to vx but only do it when the ball is already going fast, we get something that works pretty well!

And here’s what that looks like:

Here’s the final code:


Thank You very much!!