Python Forum
AttributeError: 'tuple' object has no attribute 'move'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError: 'tuple' object has no attribute 'move'
#1
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!!
Reply
#2
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.
Reply
#3
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  AttributeError: 'str' object has no attribute 'size' russoj5 4 7,390 Nov-15-2020, 11:43 PM
Last Post: deanhystad
  Object has no attribute 'replaceall' ? peterp 2 7,114 Nov-10-2020, 09:23 PM
Last Post: buran
  Calling an class attribute via a separate attribute in input wiggles 7 2,834 Apr-04-2020, 10:54 PM
Last Post: wiggles
  AttributeError: 'list' object has no attribute 'g_s' NitinL 6 3,330 Mar-31-2020, 10:24 AM
Last Post: pyzyx3qwerty
  How to make tkinter object move endlessly JacobTroubler 2 4,571 Dec-25-2019, 01:29 AM
Last Post: woooee
  ERROR NoneType object has no attribute content denizkb 1 2,589 Nov-21-2019, 01:18 PM
Last Post: denizkb
  Cant move object in game mrsneakys 1 2,215 Mar-25-2019, 01:01 PM
Last Post: ichabod801
  text = str(text.encode('utf-8')) AttributeError: 'float' object has no attribute 'enc ulrich48155 2 8,659 Jul-31-2017, 05:21 PM
Last Post: ulrich48155

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020