hi everyone! I have two files, main.py and sprite_class.py. sprite_class.py is in a separate folder called lib. here's a quick diagram:
------------------------------------
/folder engine/
main.py
/folder lib/
sprite_class.py
------------------------------------
...sprite_class.py contains a class called Sprite:
# sprite class
class Sprite():
def __init__( self, start_x, start_y, image_path ):
self.x = start_x
self.y = start_y
self.starting_y = self.y
self.image_path = image_path
self.sprite = pygame.image.load( self.image_path )
since i'm kind of rusty when it comes to import statements, I created a small def. function to handle it for me. also at the bottom, I import my sprite_class.py file:
def CD( Dir_String ):
sys.path.append( Dir_String )
# changes the system's current dir. path to specified path
CD( "/lib" )
import sprite_class
Now, the only problem I have is trying to run the class in main.py. I know how to run def. statements, but how do you run classes?
Any hints?
Thank you in advanced!