Implement Running
00:00 The third task that I can see here is that if the player runs away, the game concludes. This is the third option that the player can do.
00:09
It might be tempting to use an else
block here, but we have not done any sort of safeguarding against other inputs so far. We’re relying the user really inputs A
, H
, or R
.
00:18
So I will stick with an elif
block and be explicit about the action. I’m going to say action ==
and then we are looking at running, so "R"
.
00:30
Then I want the game to end. Well, so far, that just means maybe printing a message, "You
ran away."
Stick with that for now. Because currently this is just running once, that means the script ends here. It’s just a sequential run of code.
00:49
And now if the action is "R"
, the player ran away and the game ends, let’s give it a try. All right, I want to run, r
, ran away. But as you saw before, attack and heel also ended the script, which of course isn’t great.
Become a Member to join the conversation.