Just set vx and vy when the player throws it. You can adjust g to taste.
Should be pretty close. At the very least you’ll get the perfect bounces. There are improvements that could be had. Here are a few of them that may be of interest:
Possible improvements:
The sprite needs to be outside of walls when it starts and throughout the motion. If it’s in a tight area, or it’s started inside a wall, then you need to move it out of the wall first.
Usually not an issue if created inside the players collision area, and it’s given enough room to move around.
There can be energy loss with vertical bouncing at times. The sprite will bounce lower after a few bounces.
One reason for this is variable dt. You can help correct this by replacing self.vy*dt in all expressions with self.vy*dt+0.5*g*dt*dt.
Bouncing is done by checking where the ball will be a frame later. You can get more precise bounces by calculating when the wall is hit exactly before bouncing then moving again with the remaining time. Not really necessary but has advantages for very fast sprites.
A final idea is to only use integers for position and speed, and always use a fixed dt. This complicates it a bit but it removes energy loss from rounding caused by floating point numbers.