Brick Breaker - Advanced physics of the ball bouncing off the platform

0 favourites
From the Asset Store
Bouncing ball
$9.99 USD
Template for a bouncing ball game, fully documented in comments and video
  • Hello everyone. I'm trying to make arkanoid like game. The biggest problem I'm facing is how the ball bounce of the platform. I have seen some posts and tutorials about brick breaking games but none of these tutorials show a way to make the ball physics great, like in arkanoid.

    In arkanoid you have a lot of control over the ball, where exactly the ball will be going. All depends on how the ball hits the platform. So far with all tutorials I have seen the ball bounce of the platform pretty much all the time in the same directions. There is no precision. It's very simple and not fun to play :(

    I was trying to find post about it here or tutorial on youtube but I couldn't find anything more than basics how to make such game. In every tutorial bouncing ball of the platform is pretty much the same, very basic.

    I might've missed a tutorial or post about it. Could you please send me such tutorial or post if it exists? If it does not exist, could you please explain to me how to make advanced ball physics system or send me an example? I don't need whole tutorial on how to make such game. The only thing I need and that I have problem with is the ball physics. I want the player to have very good control on where the ball will go.

    Sorry for my english, did my best to explain the problem I'm facing. Also I'm just a begginer in Construct 3 so indulgence will be appriciated.

    Thank you in advance!

  • Have you seen the "Pinball" example in C3? I think ball physics there is pretty good.

  • Also going to suggest Araknoid has absolutely nothing to do with physics. Use the bullet behavior, set angles of motion based on your own specific set of conditions to achieve the precision you're aiming for.

  • dop2000 thank you for the idea. I will look into it and see if I can make it work.

    oosyrag I have uesd the bullet behavior before and It's just awful. I'm trying to make it work and I have some ideas but did not have time yet to try them out.

    I will be very thankful for more ideas on how to approach this problem.

  • The line of sight behavior also will allow you to cast rays, and get the angle of reflection from colliding objects. You can then modify this angle with a spin variable for example, or simply distance from the center of the paddle.

    I wouldn't recommend using the built in "bounce of solids" property, as that does not give you much control and treats corners as rounded.

  • I realized I mixed up pinball and arkanoid :)

    Yeah, for an arkanoid game I would probably use Bullet behavior.

  • I came up with the idea... Let's say that I create a paddle with width of 180 pixels. The paddle will be made of markers. Each marker is 1 pixel wide. So lets say 1 pixel is marker 1, 2nd pixel is marker 2 etc. I know it's a lot of work to create 180 markers but the paddle will be created out of this markers so the ball will have the best precision possible. Let's say ball land on marker 1. When bullet behavior is used, I can change the angle of the ball for 180 degrees. If it hits marker 2, the angle will be 181 degrees. Marker 3 - 182, marker 4 - 183. Do you guys think it might work and the precision will be perfect? Does the engine has the capability to run this?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The engine certainly can, but it would be very clunky and inflexible to do it this way.

    Instead, you can simply get the difference of the x position between the ball and the paddle (assuming both are centered) on collision. Then using that difference, apply it to the angle of reflection. This way, you'll effectively have unlimited resolution/precision.

  • oosyrag thank you for the idea! I'm not sure If I will be able to make this work. I will let you know later.

  • dop2000 thank you for your reply. It seems that your idea worked for the guy you tried to help. I did everything you've done on the screenshot and it doesn't work. I have probably made a mistake somewhere in the process. Could you check that out please? The ball goes through the paddle sometimes, you have to restart the game but even when it's working the ball bounces off the paddle like in standard bounce of solid bullet behavior.

    drive.google.com/file/d/1oB9bAf-LacvHKD-nsl4emKqHcOOipbSL/view

    I can't find where I have done a mistake :( If I manage to make this work I will post here the result so in the future people might use this for their projects :)

  • dop2000 I managed to make this work, the movement is much better than it used to be, still lack of precision but much, much better. Do you think it can be improved somehow?

    Btw. thank you for your time I really appriciate that you help a lot of users here!

  • Glad it worked! How exactly do you want to improve it? And can you share your current code?

  • dop2000I think the precision is good enough. Thank you for your help, you are amazing!

    Is there any way to attach a file here? If anyone else in the future would need help in this matter I can leave the example here. I don't want to post the google drive because I would have to keep it up forever.

    Right now this link should work. You can give it a try if you have free time. You move the paddle with your mouse and start the game with left click.

    drive.google.com/file/d/1oB9bAf-LacvHKD-nsl4emKqHcOOipbSL/view

  • As far as I know, there is no way to attach files directly here.

    If you don't have a dead-zone in the center of the paddle where the ball bounces naturally, then you don't need this action - "set a to a>1 ? a-1 : (a<-1 ? a+1 : 0)", you can remove it.

    To change how the ball bounces off when hitting different parts of the paddle you can experiment with these values:

    Set a to clamp(a/2, -45, 45)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)