How to make a ball bounce off the sides of the screen?

I am trying to create a brick breaking game and the first thing I am trying to do is to create a ball and bounce it off on all 4 sides of the console screen, but I don’t know what do use for libraries or how to start it.

Hey @ArmaanAnand2 welcome to the forums!

Can you please provide a link to the repl?

1 Like

Sure. here you go.

1 Like

Seems like you haven’t started yet, my recommendation would be to find a way to get user input; I believe there’s a library something like conio.h that can help with this.


Is this a school assignment? Because this is a classical one …


It’s a final project for me. I just needed some help to get started with it.

From graphics point of view there are several libs you can use, but the key element is how to handle the bouncing and that is something you need to do thinking of the physics behind it.

1 Like

Sounds good, I can try that out. Thank you!

If you write code and you need basic hints ask, but as it is an assignment, no more than that (at least from me)

Well you need to detect when it hits the wall and then change something to make it go the other way, right? Once you have the code in place, it shouldn’t be too hard to figure out how to do that.

I think you said enough :slight_smile:
Luckily I am not a teacher … I guess I would be a severe one!