def __init__(self): """ Virtually private constructor. DO NOT USE 'new Events()', use 'Events.get_instance()' instead. """ if Events.__instance is not None: raise Exception( "This class is a singleton. Use 'Events.get_instance()' instead of 'new Events()'" ) else: self.link = Link.get_instance() Events.__instance = self
if __name__ == '__main__': # Initialize the pygame engine pygame.init() pygame.display.set_caption('The Legend of Zelda') # Initialize the screen screen = pygame.display.set_mode(pylink_config.PYLINK_WINDOW.size) # pylint: disable=invalid-name screen.fill((0, 0, 0)) pygame.display.flip() # Load the overworld sheet and display the starting position overworld = Overworld.get_instance() # pylint: disable=invalid-name # Load Link's sprite sheet and place him at the starting position # on the map. link = Link.get_instance() # pylint: disable=invalid-name # Init the frame rate font fps_font = pygame.font.Font(None, 30) # pylint: disable=invalid-name # Create a box for the score board score_board = pygame.Surface(pylink_config.PYLINK_SCOREBOARD.size) # pylint: disable=invalid-name # The color of the scoreboard is "nearly black". The exact color Black # is reserved for the cave and dungeon entrances and is used by the code # to detect when Link is going in there. score_board.fill((1, 1, 1)) score_board.convert() score_board_rect = score_board.get_rect() # pylint: disable=invalid-name # Initialize the clock to keep track of frame rate clock = pygame.time.Clock() # pylint: disable=invalid-name