Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pong game
#4
(Dec-22-2020, 07:28 AM)buss0140 Wrote:
(Dec-22-2020, 03:57 AM)bowlofred Wrote: That's an odd error. That value should be set within the turtle library. Do you have the ability to try another python distribution? It looks more like a problem with the turtle library than with your code...

I have been using repl.it but I have tried on IDLE using distro 3.8.5 and 3.9.1 with the same result.

I switched it to this now:
import turtle
import random
import math
class Ball(turtle.Turtle):
def __init__(self, x, y, x_vel, y_vel):
turtle.Turtle.__init__(self)
self.x = x
self.y = y
self.vx = x_vel
self.vy = y_vel
self.penup()
self.speed(0)
self.setpos(x, y)

class Paddle:
def __init__(self, x, y):
Ball.__init__(self, x, y)

class LeftPaddle(Paddle):
def __init__(self, x=5, y=500):
Paddle.__init__(self, x, y)

class RightPaddle(Paddle):
def __init__(self, x=995, y=500):
Paddle.__init__(self, x, y)

But I am getting this error now.

Traceback (most recent call last):
File "main.py", line 289, in <module>
Game()
File "main.py", line 253, in __init__
self.left_paddle = LeftPaddle()
File "main.py", line 238, in __init__
Paddle.__init__(self, x, y)
File "main.py", line 234, in __init__
Ball.__init__(self, x, y)
TypeError: __init__() missing 2 required positional arguments: 'x_vel' and 'y_vel'

I am not sure why it wants the other two arguments when I am only inheriting two of the four parameters from class Ball.
Reply


Messages In This Thread
Pong game - by buss0140 - Dec-22-2020, 02:19 AM
RE: Pong game - by bowlofred - Dec-22-2020, 03:57 AM
RE: Pong game - by buss0140 - Dec-22-2020, 07:28 AM
RE: Pong game - by buss0140 - Dec-22-2020, 07:44 AM
RE: Pong game - by buss0140 - Dec-26-2020, 05:51 PM
RE: Pong game - by MK_CodingSpace - Dec-26-2020, 10:24 PM
RE: Pong game - by buss0140 - Dec-27-2020, 02:00 AM
RE: Pong game - by ndc85430 - Dec-27-2020, 07:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to send a pong on websocket-client tomtom 0 3,869 Aug-15-2022, 05:58 AM
Last Post: tomtom
  Problem with my pong game code Than999 8 3,927 May-15-2022, 06:40 AM
Last Post: deanhystad
  scoring issues in pong wildbill 1 2,264 Aug-05-2019, 01:48 AM
Last Post: metulburr
  PING PONG GAME akea 0 5,740 May-08-2019, 04:30 PM
Last Post: akea
  Python project "pong" without any makefile sylas 5 5,072 Nov-28-2017, 05:55 PM
Last Post: Larz60+
  ping and pong run both well sylas 1 3,236 Sep-24-2017, 05:14 PM
Last Post: sylas

Forum Jump:

User Panel Messages

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