Home > other >  Python, an alien invasion game some of the problems
Python, an alien invasion game some of the problems

Time:09-23

Why _init_ () in the parameter is ai_setting, screen, ship
Why only initialize screen
Ai_settings why can direct access to the storage in another file the related Settings in the Settings of the

CodePudding user response:

Initialize the parameters of the screen is the initial screen
Ai_settings is Settings instantiation of a class object, class of data can be accessed through the object, at the start of the import setting. Py

CodePudding user response:

Super (a subclass of the self.) __init__ (parent class attribute), which in subclasses initialization function to parent __init__ function of the parent class attribute all included,
First __init__ is the initialization function, the self. The screen=is in order to let the screen to screen in all function can be used to screen, and ai_settings and ship behind function is not used, so you don't have the self. The second, ai_settings can direct access to the storage in another file the related Settings in the Settings, is due to we have defined in the alien_invasion ai_settings=Settings () # substitute ai_settings Settings (), so to be able to obtain relevant Settings