I'm (attempting) to recreate Mario level 1-1 in Pygame with Python 2.7.12. these are the two relevant files:
main.py: http://pastebin.com/HXmBdJ2a
mario.py:
http://pastebin.com/29xu1tMM
My problem is: when I run main.py, the interpreter gives me this error message:
Traceback (most recent call last):
File "C:/path/to/main.py", line 6, in <module>
import mario
File "C:\path\to\mario.py", line 7, in <module>
import main
File "C:\path\to\main.py", line 47, in <module>
game = Game()
File "C:\path\to\main.py", line 26, in __init__
self.main_loop()
File "C:\path\to\main.py", line 39, in main_loop
self.Mario = mario.Mario()
AttributeError: 'module' object has no attribute 'Mario'
Process finished with exit code 1
I'm confused, as mario.py does the class Mario. If I try to run mario.py, I get this error:
Traceback (most recent call last):
File "C:/path/to/mario.py", line 7, in <module>
import main
File "C:\path\to\main.py", line 6, in <module>
import mario
File "C:\path\to\mario.py", line 12, in <module>
sheet = pygame.image.load("../assets/images/MarioLuigiSprites.png").convert()
pygame.error: No video mode has been set
Process finished with exit code 1
Could anyone explain this to me?
EDIT: I fixed it by adding:import sys
sys.path.insert(0, "scripts")
import mario