You are using animation, so you’ll have to include a setup() function (not settings). The size() is placed within this. However, there are several issues with your script. I’ve added the setup() function, but had to make a few other adjustments to get it working:
Balls = []
class Ball:
def __init__(self, x, y, xvel, yvel, radius):
global Balls
self.x = x
self.y = y
self.xvel = xvel
self.yvel = yvel
self.radius = radius
self.r = self.radius/2
m = radius*.1
self.ball = self
fill(250)
self.drawing = ellipse(x, y, radius, radius)
Balls.append(self)
def update(self):
self.x += self.xvel
self.y += self.yvel
def checkWall(self):
if self.x > 640 - self.r:
self.xvel = -self.xvel
if self.x < 0 + self.r:
self.xvel = -self.xvel
if self.y > 480 - self.r:
self.yvel = -self.yvel
if self.y < 0 + self.r:
self.yvel = -self.yvel
def display(self):
fill(255)
ellipse(self.x, self.y, self.radius, self.radius)
def draw():
background(255)
if len(Balls) > 0:
for b in Balls:
b.update()
b.display()
b.checkWall()
def setup():
size(640, 480)
global Balls
Ball(100, 100, 20, 10, 50)
Ball(500, 300, 10, 3, 200)
There’s still some redundant code in there. You might want to look at removing what you do not need.
To learn those basics see the introduction tutorials, particularly the Overview, here
Interactive programs are drawn as a series of frames, which you can create by adding functions titled setup() and draw() as shown in the code below. These are built-in functions that are called automatically.