'How to make ball bounce off of triangle in Py.Processing?
Im building a game in processing python. It is similar to pong except the paddles can rotate thus changing the direction of the ball. There is also supposed to be a feature where if you hit a smaller ball, triangles pop up on each the top and botton making it harder to get the ball through to the other side. So the ball is supposed to bounce off of the triangle and and make a 45 degree angle in reference to the x and y axels. Im having a hard time solving this problem. picture of game, white circle is the ball that I that is supposed to bounce on the triangle. My initial thought was to make an if statement containing two mx + c functions as follows.
if triangle_score == 1 and ball_y >= (ball_x * -1) + 350 and ball_y >= (ball_x - 450): ball_dx = ball_dx * -1 ball_dy = ball_dy * -1
Needless to say it didn't work very well. Does anyone know processing. Would be sooo thankful for any help I can get.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
