Python Forum

Full Version: AttributeError: 'tuple' object has no attribute 'move'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am really dying to solve this issue. Once I add enemy_0.move() or enemy_0.draw I just get black screen and this error:

https://pastebin.com/HjuWZUTV

Error:
Traceback (most recent call last): File "C:\Users\QR88UL\Google Drive\python\game.py", line 150, in <module> new_game.run_game_loop() File "C:\Users\QR88UL\Google Drive\python\game.py", line 78, in run_game_loop enemy_0.move(self.width) AttributeError: 'tuple' object has no attribute 'move'
Since I'm still new and following this Zenva course I just want to finish it as I find it good and move somewhere else.

Thank you for your help!!
You have a typo in your code. You need replace this:
enemy_0 = NonPlayerCharacter = ("enemy.png", 20, 600, 50, 50)
to this:
enemy_0 = NonPlayerCharacter("enemy.png", 20, 600, 50, 50)
This is line 52 of your code from Pastebin. You need to make an instance of NonPlayerCharacter class, but you have the symbol of equality, and you have tuple instead NonPlayerCharacter.
The problem stems from line 52:

enemy_0 = NonPlayerCharacter = ("enemy.png", 20, 600, 50, 50)
This line instantiates enemy_0 as equal to NonPlayerCharacter and both are equal to the tuple ("enemy.png", 20, 600, 50, 50). To correctly instantiate enemy_0 as a NonPlayerCharacter instance, this line should be:

enemy_0 = NonPlayerCharacter("enemy.png", 20, 600, 50, 50)