ArsThaumaturgis/Panda3DTutorial.io

Lesson 5: AttributeError: 'Game' object has no attribute 'updateKeyMap'

Closed this issue · 0 comments

Hey! My code is the same as it's in the reference code, but when I run the game it crashes with the error message saying "AttributeError: 'Game' object has no attribute 'updateKeyMap'".

Update: I realized that the updateKeyMap() function is wrongly idented, my bad!

    # .... rest of the code ....

    self.keyMap = {
        "up" : False,
        "down" : False,
        "left" : False,
        "right" : False,
        "shoot" : False
    }

    self.accept("w", self.updateKeyMap, ["up", True])
    self.accept("w-up", self.updateKeyMap, ["up", False])
    self.accept("s", self.updateKeyMap, ["down", True])
    self.accept("s-up", self.updateKeyMap, ["down", False])
    self.accept("a", self.updateKeyMap, ["left", True])
    self.accept("a-up", self.updateKeyMap, ["left", False])
    self.accept("d", self.updateKeyMap, ["right", True])
    self.accept("d-up", self.updateKeyMap, ["right", False])
    self.accept("mouse1", self.updateKeyMap, ["shoot", True])
    self.accept("mouse1-up", self.updateKeyMap, ["shoot", False])

    def updateKeyMap(self, controlName, controlState):
        self.keyMap[controlName] = controlState
        print (controlName, "set to", controlState)

`