Skip to content
NEED SOME URGENT HELP: How do i fix this attribution error
Profile icon
ArtemisNightingale

this is a part of an entry for completion that's deadline is in a fed says. I had run into some errors and got some help from someone on this board. then I went I fixed the rest of it but now I am stuck on this attribution error that I don't know how to fix. This is the first time I am working with pygame, so I am pretty much a total beginner. any help again would be greatly appreciated.

Screenshot 2021-10-30 8.37.13 PM

You are viewing a single comment. View All
Profile icon
Coder100

hi, you made a typo:

image

the correct way to initialize a function is to use __init__
so do that

def __init__(self): pygame.init() self.running, self.playing = True,False self.UP_KEY, self.DOWN_KEY,self.START_KEY self.BACK_KEY = False, False, False, False self.DISPLAY_W, self.DISPLAY_H = 480,270 self.display=pygame.Surface((self.DISPLAY_W,self.DISPLAY_H)) self.window = pygame.display.set_mode(((self.DISPLAY_W,self.DISPLAY_H))) self.font_name = "8-BIT WONDER.TTF" self.BLUE,self.WHITE = (52,64,235),(255,255,255) self.main_menu = MainMenu(self) self.options = OptionsMenu(self) self.options = CreditsMenu(self) self.curr_menu = self.main_menu
Profile icon
ArtemisNightingale

@Coder100 thanks a lot! but did you spot any other typos by chance because no I have an attribution error of, Game object has no attribute UP_KEY

Profile icon
Coder100

@ArtemisNightingale don't forget to indent all of this:

image

so it has all the same indentation as the class.

Profile icon
ArtemisNightingale

@Coder100 got it! but do you know how to fix the syntax error that's popping up for line 2? i don't see whats wrong

Profile icon
Coder100

do you mean import menu or from menu import * because when you import using from import you have to specify what you want to import. @ArtemisNightingale

Profile icon
ArtemisNightingale

@Coder100 understood. I corrected it to "from menu import*". I think it almost worked but now they're saying there is a type error.