![]() ![]() ![]() (This is for Processing instead of p5.js, but the same concepts. You can read more about this in the collision detection tutorial. This causes the ball to bounce off every side of the window. Because I am using angular movement, I need to do this by modifying the ball's angle value, and I am not sure how to set it so it bounces correctly. Similarly, it uses another if statement to check whether the ball has gone off the top or bottom of the window, and reverses the ySpeed variable if it has. I'm not sure why it does this - I am trying to have the ball flip its X velocity on a horizontal collision, and flip its Y velocity on a verticle collision. When a ball hits a wall on any side, the ball bounces right back on the same angle The ball comes in at angle X ( lets say 30 ).īouncing off with the equation 360-ballangle works for the left and right wallsġ80-angle works for top and bottom walls.Įdit Sorry for the vagueness - heres whats going on I'm trying to bounce a ball off of a wall based on angular movement.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |