I can not find whats wrong with my code, it says that it's a type error but I cant find where.
I have been trying to figure out why the rect isn't considered to by in the right format but I cannot figure out why. Help would be appriciated, I am a beginner programer and have only been coding in python for about a week.
from players import Player
import pygame
import sys
pygame.init()
window_width, window_height = 1200, 800
window = pygame.display.set_mode((window_width, window_height))
pygame.display.set_caption("pong")
clock = pygame.time.Clock()
fps = 144
x = 50
y = 100
p_speed = 6
color = 200, 0, 0
width = 30
height = 100
def main():
p = Player(x, y, p_speed, window, width, height, color)
while True:
clock.tick(fps)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
p.draw()
pygame.display.update()
main()
import pygame
class Player():
def __init__(self, x, y, p_speed, height, width, window, color):
self.x = x
self.y = y
self.speed = p_speed
self.height = height
self.width = width
self.window = window
self.color = color
def draw(self):
rect = pygame.Rect(self.x, self.y, self.height, self.width)
pygame.draw.rect(self.window, self.color, rect)