Day 7 NuCamp

Workshop assignment / Collabs on Zoom / Restarting Game with function

Kenny Hin
2 min readJul 3, 2022

Got to experience my first workshop and work collaboratively with a team to develop a game. It wasn’t what i expected. Instead of trying to figure it out altogether task by task, the more experienced developer blazed through it. With that said, I was still able to learn a lot by observing their thought process.

Restarting the game

FEEDBACK from instructor:

This was apparent to me watching my peers code the efficiently but my instructor could tell I “brute forced” my way through the code. I hardcoded most of it, copy and pasting instead of manipulating my variables. He did say since its the first week, he doesn’t expect the most efficient code, but as long as the code works and I understand how it runs. A couple bonus questions, like restarting the game and giving options for the user to quit the game, I did accomplish and I do want to highlight.

To restart the game, i wrapped my entire game in a function with Line 4:

def game ( )

Also have to make sure you call the function so the game runs — Line 170

Now wherever the game ends, in my case, when dragon or character HP is ≤= 0 , I will prompt the user to restart the game and based on INPUT, it will either restart the game or exit.

Line 84–92

Indicates the dragon has been defeated. Line 86–87 prompts the user to play again, allowing y/n accompanied by the helper method lower( ) to lowercase any input so that line 88/90 can run based on the input.

If “y” is the input, game() function is called again, restarting the game.

--

--