I import this module in the main program with the line from classe_recto2 import Recto. It will import the class Recto (I can print a class Recto object) but when I call the function next_circle I get NameError: name 'next_circle' is not defined.
The whole module looks like this:
import pygame
class Recto:
def __init__(self,posizione, colore,snippet,circles_list, counter_snippet, volume):
self.posizione = posizione
self.colore = colore
self.snippet = snippet
self.cerchi = circles_list
self.counter_snippet = counter_snippet
self.volume = volume
self.first_position = self.cerchi[0][0]
self.position = self.cerchi[0][1]
self.height = self.cerchi[0][2]
self.direzione = self.cerchi[0][3]
def snippet_volume(self):
pygame.mixer.Sound.set_volume(self.snippet, self.volume)
def next_circle(self):
circle = []
if self.height == 0:
new_height = 0
self.height = new_height
else:
new_height = self.height -2
self.height = new_height
if self.direzione == 1 and self.position < self.first_position +100:
new_position = self.position+10
self.position = new_position
if new_position > self.first_position +100:
new_position = self.first_position +100
self.position = new_position
self.direzione = -1
else:
self.direzione = 1
if self.position == self.first_position +100:
new_position = self.position -10
self.position = new_position
self.direzione = -1
if self.direzione == -1 and self.position > self.first_position:
new_position = position -10
if new_position < self.first_position:
new_position = self.first_position
self.position = new_position
self.direzione= 1
else:
self.direzione = -1
if self.direzione == -1 and self.position == self.first_position:
new_position = self.position+10
self.position = new_position
self.direzione = 1
circle.append(self.first_position)
circle.append(new_position)
circle.append(new_height)
circle.append(self.direzione)
return circle
Sorry, I know it is a lot of code but I thought being able to see it all could make it easier to pinpoint the problem. Thank you.