Python Forum
[PyGame] Can't convert integer values to float values for Pong - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: [PyGame] Can't convert integer values to float values for Pong (/thread-35567.html)



Can't convert integer values to float values for Pong - game_slayer_99 - Nov-18-2021

I've been working on my own version of Pong, and at the moment, I have been working on getting the ball to bounce off of the four sides of the screen. The ball successfully bounces off each side, but I want to slow the ball down, but in order to do that, I have to use decimal values to lower the speed, which aren't allowed when using rect values. How do I change my code to do that? I attached the code for the ball.


RE: Can't convert integer values to float values for Pong - metulburr - Nov-18-2021

True position added to velocity plus speed equals the new true position of the ball

Here is my ball class in a pong game I made as an example. In one phase of the game, there are ghost balls which spawn at random locations and at different speeds. So the class is made to handle different ball objects.

https://github.com/metulburr/pong/blob/74779b0e3083984ea550ab62aff3d9d746a0439e/data/ball.py#L89