This site requires JavaScript, please enable it in your browser!
Greenfoot back
RSekander
RSekander wrote ...

2018/5/29

I'm making a brick breaker game for a school project. I was wondering what code to write for the ball to bounce back in the angle it came off of walls/paddleboard?

RSekander RSekander

2018/5/29

#
I am completely lost for the bounceBack method. How do I get it to bounce back of the same angle it came in? public void act() { if (getOneIntersectingObject(Wall) || getOneIntersectingObject(PaddleBoard()) { bounceBack(); } } public void bounceBack() { }
danpost danpost

2018/5/29

#
RSekander wrote...
I am completely lost for the bounceBack method. How do I get it to bounce back of the same angle it came in? << Code Omitted >>
Bouncing off a wall will involve changing horizontal direction while bouncing off a paddle will involve changing vertical direction. That being said, you should split up the conditions into two separate if statements.
You need to login to post a reply.