Найти - Пользователи
Полная версия: помогите разобраться с ошибкой
Начало » Python для новичков » помогите разобраться с ошибкой
1
asdfr
вот код
 import math
import pygame
from pygame.locals import *
window = pygame.display.set_mode((600, 600))
pygame.display.set_caption('Hello')
screen = pygame.Surface((600, 600))
f=open('11.txt','r')
class Triangle:
    def __init__(self, p1, p2, p3):
        self.poligon_color = (255, 0, 0)
        self.poligon_points = [p1, p2, p3]
        self.poligon_width = 0
    
    def render(self):
        pygame.draw.polygon(screen,self.poligon_color,self.poligon_points, self.poligon_width)
class Rect:
    def __init__(self, p,w):
        self.rect_color = (255,0,255)
        self.rect_pos = [p,w] #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
        self.rect_thickness = 0
        
    def render(self):
        pygame.draw.rect(screen,self.rect_color, self.rect_pos, self.rect_thickness)
class Circle:
    def __init__(self,cp, r):
        self.circle_color =(255,100,255)
        self.circle_pos = [cp]
        self.circle_radius = [r]
        self.poligon_width = 0
    
    def render(self):
        pygame.draw.circle(screen, self.circle_color,self.circle_radius,self.circle_pos, self.poligon_width)
d=[]
for s in f:
    b=s.split(',') 
    
    if b[0] == "triangle":
        p1 = (int(b[1]), int(b[2]))
        p2 = (int(b[3]), int(b[4]))
        p3 = (int(b[5]), int(b[6]))
        d.append( Triangle(p1, p2, p3) )
        
        
    elif b[0] == "rect":
        p = (int(b[1]), int(b[2]))
        w = (int(b[3]), int(b[4]))
        d.append( Rect(p, w) )
        
    elif b[0] == "circle":
        cp = (int(b[1]), int(b[2]))
        r = (int(b[3]))
        c = Circle(cp, r)
        d.append(c)
        
    
    
        
done = True
while done:
    for e in pygame.event.get():
        if e.type == pygame.QUIT:
            done = False
    screen.fill((50,50,50))
    
    for obj in d:
        obj.render()
    
    
    
    window.blit(screen, (0,0))
    pygame.display.flip()
вот ошибка
Traceback (most recent call last):
File “C:\Users\1\Desktop\pp\15.py”, line 75, in <module>
obj.render()
File “C:\Users\1\Desktop\pp\15.py”, line 36, in render
pygame.draw.circle(screen, self.circle_color,self.circle_radius,self.circle_pos, self.poligon_width)
TypeError: argument 3 must be sequence of length 2, not 1
Соответственно если закаментировать
 elif b[0] == "circle":
        cp = (int(b[1]), int(b[2]))
        r = (int(b[3]))
        c = Circle(cp, r)
        d.append(c)
то все отлично работает
помогите найти ошибку.пожалуйста)))
вот тхт файл который подгружаеться для фигур
triangle,300,200,150,300,200,100
rect,40,40,40,40
circle,100,300,75
asdfr
всем спасибо
разобрался сам
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB