#Starting import and opening window
import pygame
import math
from pygame import *
from Characters import *
import os
screen_width = 1900
screen_height = 950
player_bullets =
pygame.init()
clock = pygame.time.Clock()
screen = pygame.display.set_mode((screen_width,screen_height))
#movement varibles
x = 10
y = 10
width = 40
height = 60
vel = 2.5
radius = 25
#Running the code
run=True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
#Creating a user avatar
class Characters:
def init(self, image, center):
super().init()
self.image = pygame.image.load(image)
self.rect = self.image.get_rect()
self.rect.center = center
screen.fill((0,0,0))
pygame.draw.circle(screen, (0, 255, 0), (x, y), radius)
pygame.display.update()
player1 = pygame.image.load('RedCharacter.PNG')
#WASD movement
keys = pygame.key.get_pressed()
if keys[pygame.K_a]:
x -= vel
if keys[pygame.K_d]:
x += vel
if keys[pygame.K_w]:
y -= vel
if keys[pygame.K_s]:
y += vel
#Projectile class
class projectile(object):
def __init__(self,x,y,radius,colour):
self.x = x
self.y = y
self.radius = radius
self.colour = colour
self.vel = 8
def draw(self, screen):
pygame.draw.circle(screen, self.colour, (self.x, self.y), self.radius)
#Array to store bullets
bullets = []
#Shooting bullets
if event.type == pygame.MOUSEBUTTONDOWN:
bullets.append(projectile(round(x + width//2), round(y + height//2), 6, (250,250,250)))
#Removing bullets outside of borders
for bullet in bullets:
projectile.draw(screen)
if bullet.x < 500 and bullet.x > 0:
bullet.x += bullet.vel
else:
bullets.pop(bullets.index(bullet))
#Borders of the screen
if x < radius:
x = radius
if x > screen_width - radius:
x = screen_width - radius
if y < radius:
y = radius
if y > screen_height - radius:
y = screen_height - radius
pygame.display.update()
That is the current code, the problem is when shooting the bullets. Just don’t know how to fix the error; “Traceback (most recent call last):
File “M:\Game - Programming project\wasd.py”, line 77, in
projectile.draw(screen)
TypeError: projectile.draw() missing 1 required positional argument: ‘screen’”