This has me stumped so I'm hoping someone can help me out.
I need to be able to calculate the new angle of a bullet or a ball when it hits a wall.
Imagine Arkanoid (although that's not what I'm making).
Then imagine a ball moving down and right towards a wall at 135 degrees - like this \.
Essentially both xspeed and yspeed would be 1 in this simple example.
The only way I can think of is the "normal" (I think) way of changing the direction of the ball - ie. When it hits that right wall I'd make xspeed=-xspeed to change the direction.
The thing is - I'm not interrested in changing the xspeed and yspeed variables directly like this.
I'd like some clever way (if there is one) to calculate my new angle, so in this case the angle would change from 135 to 225, and then calculate the speeds depending on the angle.
Can anyone help me out?
I need to be able to calculate the new angle of a bullet or a ball when it hits a wall.
Imagine Arkanoid (although that's not what I'm making).
Then imagine a ball moving down and right towards a wall at 135 degrees - like this \.
Essentially both xspeed and yspeed would be 1 in this simple example.
The only way I can think of is the "normal" (I think) way of changing the direction of the ball - ie. When it hits that right wall I'd make xspeed=-xspeed to change the direction.
The thing is - I'm not interrested in changing the xspeed and yspeed variables directly like this.
I'd like some clever way (if there is one) to calculate my new angle, so in this case the angle would change from 135 to 225, and then calculate the speeds depending on the angle.
Can anyone help me out?