I have been working over ex43 and making my own game.
I have been stuck for a very long time trying to understand the Engine.
I have done many print() statements, used vs code debuger, pdb, even tried pudb(wouldn’t work).
light up google, Youtube and this forum. Over time the fog was lifting but was still murky. I went over Classes again then keep studying backwards. on Exercise 41: Learning to Speak Object-Oriented, something kinda clicked. so I walked through the engine and came up with this.
class Engine(object): def __init__(self, scene_map): #__init__ self and scene_map argument self.scene_map = scene_map def play(self):# method (1) play takes instance # as first arugment(self) # self is all we need to get scene_map current_scene = self.scene_map.opening_scene() # set current_scene to an instance of scene_map # and get the opening_scene funtion (from Map()) last_scene = self.scene_map.next_scene('death') # set last_scene to an instance of scene_map # and get next_scene funtion (from Map()) # with the 'death' parameters while current_scene != last_scene: # current_scene and last_scene from play() # while current_scene does not equal last_last # (or while scene is not 'death') next_scene_name = current_scene.enter() # set next_scene to an instance of current_scene and call it # with the enter() funtion current_scene = self.scene_map.next_scene(next_scene_name) # set current_scene to scene_map, and call it with next_scene that # takes self and next_scene_name as paramiters # be sure to print out the last scene current_scene.enter()
If I’m on the right track, I’ll work on this and then Map() next until I can make my own.