Syntax error in Python/pygame -
this question has answer here:
- nested arguments not compiling 1 answer
i'm learning python/pygame , i'm doing physics tutorial. unfortunately, think made in older version of python. copied code in video exactly, when run it returns "failed run script - syntax error - invalid syntax(physics.py, line 7)". i'm sure it's stupid , obvious i'm missing, answer go long way me!
import os, sys, math, pygame, pygame.mixer pygame.locals import * screen_size = screen_width, screen_height = 600, 400 class mycircle: def __init__(self, (x, y), size, color = (255,255,255), width = 1): self.x = x self.y = y self.size = size self.color = color self.width = width def display(self): pygame.draw.circle(screen, self.color, (self.x, self.y), self.size, self.width) screen = pygame.display.set_mode(screen_size) my_circle = mycircle((100,100), 10, red) my_circle_2 = mycircle((200,200), 30, blue) my_circle_3 = mycircle((300,150), 40, green, 4) my_circle_4 = mycircle((450,250), 120, black, 0) fps_limit = 60 run_me = true while run_me: clock.tick(fps_limit) event in pygame.event.get(): if event.type == pygame.quit: run_me = false my_circle.display() my_circle_2.display() my_circle_3.display() my_circle_4.display() pygame.display.flip() pygame.quit() sys.exit()
you're using python 3. tuple parameter unpacking removed in 3.x, have change this:
def __init__(self, (x, y), size, color = (255,255,255), width = 1): self.x = x self.y = y self.size = size self.color = color self.width = width
to:
def __init__(self, position, size, color = (255,255,255), width = 1): self.x, self.y = position self.size = size self.color = color self.width = width
Comments
Post a Comment