this is using a x speed and y speed variables, to determine the velocity. When the ball hits a wall, it inverts the velocity, and checks the start and max angle, to determine the vector (average) angle for the bounce. there is a way to change the level of bouncyness and the starting speed and friction of the ball.
feel free to use this, just give credit :)