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

2017/1/9

bouncing realistically of edges

Kieranwilko98 Kieranwilko98

2017/1/9

#
I'm making a mini golf game and I need my ball to bounce realistically of the edges of my grass, which is an object, and I'm not sure how to do it, the edges of my grass on the x-axis are 80-520 and on the y-axis 170-330. I'm not very good at coding and would be a great help for my coursework so if anyone could help that would be great.
danpost danpost

2017/1/9

#
It might be easiest to add border actors around the grass. They can all be of the same class type with the vertical ones rotated. Then, when encountered by the ball, you can determine how to adjust the position and direction of the ball by the rotation of the border and the original direction of movement of the ball.
You need to login to post a reply.