Cops & Robbers

Zombies and Scientist!

Cops & Robbers
See Jan's super cool Cop and Robbers Game below - or should I say Zombies and Scientist! 🧟
 
This week in Game Dev Club, our Modders have been coding a brand new game: Cops and Robbers. In this top-down tile game, the players take control of a robber who is sneaking through the maze to get to the treasure chest. However, our robber isn't alone! Throughout the maze, there are several cops patrolling and if they spot our robber they will pick up speed and charge after them. If the cops catch up to the robber, it is game over - so stealth is key to this game!
 
In today's Guided Hack, we decide to make this game of cat and mouse even more interesting. By adding a key-code into our game that opens up the chest, the robber now has to spend more time looking through the maze for the note containing the code. In addition, once the key-code has been entered into the treasure chest the robber now has to make an escape through one of the 4 starting points - but only one is open and the rest are closed down so don't get cornered by the cops when running for the exit! To do this we code two functions; one which generates the keycode for the player to input and one which creates the escape route for the robber. We also edit the overlapping code for the player sprite and the chest sprite so that instead of rewarding us points upon contact, it will now ask for the code and check if it matches with the randomly generated one.
 
This Guided Hack gets our coders to consider strings and integers and the difference between them as we code our robber sprite to say the number held in the key-code variable. This takes us onto this week's coding skill: String Casting. In this coding skill, we use a Python function known as casting. This turns a integer (in this case our key-code number) and converts it to a string so that the robber can say it. A very useful Python function to keep in your back pocket for future projects 🙂

Categories

Chat to our mentors