Python Forum
[PyGame] Can't convert integer values to float values for Pong
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Can't convert integer values to float values for Pong
#1
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.

Attached Files

Thumbnail(s)
   
Reply
#2
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/7...all.py#L89
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation pong paddles wont move skullkat232 5 2,281 Feb-13-2023, 03:53 PM
Last Post: Vadanane
  Problem with my pong code Than999 3 3,368 Oct-22-2021, 08:50 AM
Last Post: Qanima
  Game “Pong” I have problems with the code BenBach18 2 3,447 Jan-10-2021, 05:16 PM
Last Post: michael1789
  [PyGame] Creating Pong in Pygame Russ_CW 2 2,774 Oct-11-2020, 11:56 AM
Last Post: Russ_CW
  TypeError: integer argument expected, got float abscorpy 1 6,793 Oct-17-2019, 05:40 PM
Last Post: ichabod801
  Modifying Class values Tridium 2 2,204 Aug-05-2019, 10:29 PM
Last Post: Tridium
  Trying to make a simple pong game. kevindadmun 1 3,865 Aug-05-2019, 06:39 AM
Last Post: kevindadmun
  Smiley Pong Help Jasmineleroy 6 4,647 May-22-2019, 11:36 AM
Last Post: metulburr
  [PyGame] How do I add more balls to basic Pong game? JUtah 2 4,370 Apr-18-2019, 08:40 PM
Last Post: JUtah
  [PyGame] Pong game key.event problem erickDarko 2 4,128 Dec-12-2018, 03:17 PM
Last Post: erickDarko

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020