top of page

In CrimePeeper, you are on the hunt for the locations of various crimes within the area. Each location within the area is represented by a tile on a grid. Clicking on a tile will unveil the amount of crimes occurring within the adjacent tiles, but if that tile contains a crime, you will lose! To find the crimes without being caught, you need to right click the tiles you think are crimes, but if you are wrong, about a tile, you will lose.

The game can be played above. it is also available on itch.io here. The code, artwork and executable are available on GitHub here. Some screenshots of the game are shown below. There is also a video below to give a brief overview of the game. A description of the design process is then given along with some details about original plans, difficulties and techniques learned.

Design

This was the first game I developed using Unity, and as such there were a lot of firsts in the development. For each level a number of tile objects were placed that were based on a single tile prefab. Each tile has a script attached that contains some properties for the tile. A controller script is then used to access and modify these properties. I originally planned to have a 2 dimensional array in the controller script to hold each of the tile objects but I had a problem getting that to display on the Unity editor in order to attach the tile objects to the array, so instead I used a 1 dimensional array.

The controller contains a method to initialise the board each time the level is entered. For each of the tiles in the array, the corresponding tile sprite is changed to the initial unclicked state. A random amount of crime tiles is generated within a certain range for that level and then distributed randomly throughout the board, marking the relevant tiles as crimes using the properties within their iteration of the tile script. Once I added more levels I had to figure out a way to modify the amount of crimes that could be generated. I used the built in OnEnable function which allowed me to trigger the initialisation each time the level was loaded and pass in the build index of the level in question to modify the amount of crime tiles.

During the game, the sprites associated with the different potential states of the tiles are changed depending on which tile is clicked and its properties. In order to derive whether a tile has been clicked on, I have a method which takes the position of the mouse and returns whether that position overlaps with a 2D box collider that has been attached to the tile. I can then listen for mouse click inputs when it is within the collider in order to change the state of the tile. The tiles will work out how many crime tiles are adjacent to it when they are clicked, so the processing is done only when necessary, removing the need to find this information out for tiles that are never clicked. To find this out for a corresponding tile, the tiles adjacent to it are found and a value is incremented for each one that is a crime. Then the corresponding sprite it generated. If the tile is already clicked this is bypassed and if it is a crime there will be different behaviour. To find the adjacent tiles, the tile positions are converted into 2D iterators and then the 2D positions of the adjacent tiles are converted back to get their 1 dimensional positions in the array.

I needed to listen for a sequence of inputs for the Konami Code trigger (see below for more details about this trigger), so to do this I stored the sequence into an array. This can then be used to increment a counter each time the relevant button is pressed, with the counter resetting if the input received is different to what is expected in the next part of the array. Flags were also used to work out whether or not the code has been triggered for the first time. To generate the different text pop ups, multiple UI’s were created in the level. For these, as well as for the start and end screens, TextMesh Pro was used. This allowed for more freedom to customise the font than the default options available in Unity. I initially planned to contain an animation for the title on the main screen to change its TextMesh Pro properties to emulate it going from a faded and blurred title to come into sharper focus, but I wasn’t able to change these properties at different key frames in the animator. I used the Scene Manager in Unity to switch between the different levels and start/end screens. In order to restart the level I was one, I needed to load the build index of the active scene into PlayerPrefs, to store that information for access in a different scene.

In order to implement the ability in the game to open up the board when no crimes are present in a clicked tile, I used a recursive method. This method is called within the code that listens for inputs in the case that the tile clicked on has no adjacent crimes. This method then finds all of the adjacent tiles in the array of tile objects. For each of these, if there are 1 or more adjacent tiles that are crimes, it will change the tile to display the relevant sprite and then move on, but if any of these similarly have 0 adjacent crimes, then the recursive method call is used for that sprite. In this case, only the adjacent tiles that haven’t already been clicked will be checked, so no redundant checks are made.

Once the code for the basic level was mostly worked out, it was fairly trivial to create new levels as they could each use their own version of the controller script. I did have to attach the script to a background object in the scene in order for it to trigger when is level is entered, but this allowed me to have different arrays of tiles for each level that could then be referenced and modified in their corresponding instance of the controller script.

 

Artwork And User Interface

I initially decided to use GIMP for the art assets in the game and learn to become adequate at using that as I learned Unity. It proved to be difficult to become comfortable using GIMP as even for the most basic sprites it took some time to find the tools to create them. As such, combined with time constraints, the initial sprites I created for the game to test with that were originally intended to be prototypes, ended up being used in the final game. As a result, I feel that the artwork looked a bit basic and could have been more polished. I have decided to scrap GIMP and instead use Photoshop in future projects to create art assets as I had briefly used it before and remember it being somewhat more intuitive to use. I hope to create more polished artwork for future games along with better presented UI. The UI was the last element that I worked on and proved to be fairly involved as there are various screens and pop ups depending on what happens in the game. As a result I had similar time constraints with making these elements more presentable as it was late in the night by the time I was finished with them. Hopefully this initial learning experience will aid me in improving the UI for future projects.

Konami Code

There is an easter egg in the game that can be triggered by entering the Konami Code (up, up, down, down, left, right, left, right, b, a, enter). When this happens the game will switch between normal mode and criminal mode. In criminal mode, the images relating to the crime tiles will change in regards to the change in context of the game. Instead of the tiles being crimes, they are places to rob and instead of the game over images being of you getting caught by the criminals, they are of you getting caught by civilians. It can be toggled on or off with repeated entering of the Konami Code, but the first time it is triggered, a text box will appear to inform the user of the change in mode and what it signifies. Likewise, if you untrigger criminal mode again, a text box will appear to explain that you have reset the game mode back to normal. After this is done once, the mode can still be triggered on and off, but when this happens there will simply be a short pop up to inform the viewer that criminal mode has been turned on or off.

bottom of page