I am trying to write a boid program using python, I have a program called boid.py which defines the boid class and another program called flocking practice.py which is supposed to use the create the boids and draw them on the screen. the code in boid.py is:
import numpy
import random
from pygame.locals import*
pg.init()
class Boid(object):
def __init__(self,pos):
object.__init__(self)
self.pos = [pos[0]/2,pos[1]/2]
self.vel = []
self.accel = []
def draw(self,screen):
pg.draw.circle(screen,[255,255,255],self.pos,5)
and the code in flocking practice.py is:
import pygame as pg
import sys
clock = pg.time.Clock()
screen_dimensions = [1000,800]
screen = pg.display.set_mode(screen_dimensions)
boid_list = []
flock_size = 1
white = [255,255,255]
for i in range(flock_size):
new_boid = boid.Boid(screen_dimensions)
boid_list.append(boid)
while True:
for event in pg.event.get():
if event.type == pg.KEYDOWN:
if event.key == pg.K_ESCAPE:
sys.exit()
if event.type == pg.QUIT:
sys.exit()
screen.fill(0)
for i in range(len(boid_list)):
boid.Boid.draw(screen)
clock.tick(60)
pg.display.update()
when I run flocking practice is gives me an error message saying
Traceback (most recent call last):
File "C:\Users\Chris\Documents\python programs\flocking practice.py", line 27, in <module>
boid.Boid.draw(screen)
TypeError: draw() missing 1 required positional argument: 'screen'
[Finished in 1.219s]
why is it saying that it's missing the positional argument when I feed it into the method?