Test Pieces:
Code Test Pieces:
I wanted to see if the code that I was going to use would work I first started by opening up a brand new Unity project and creating my home screen, I done this by creating a plain background and adding 3 buttons, one called ‘PLAY’ another called ‘HELP’ and the last called ‘QUIT’. I created these to navigate around the test pieces and also to check if this code worked. This is so when it comes to creating the actual final piece, I will know what to do and that it works.

I then went on to creating a script for the ‘QUIT’ button and this involved not much detail or effort at all and this was done my creating a public void for the button, when it was pressed it would activate the code ‘Application.Quit’ and what this did is it then would close the game and that’s it. I done this so there is a way to then close the game rather than having to restart the pc.

After this I then went and created the script for changing scenes and what this would do if a certain button that this was binded to would take you to the scene that you wanted. For example if I binded this to a options button and then set it to sent you there then if it was click it would take the player there. I created this code to save a lot of time and this so I don’t have to create a bit of code for every button. I also created this to make sure that the code worked.

I then went to create the help screen and this was to make sure that my scene changer would work properly. This was done by creating anew scene and adding a plain background, some text telling the player the controls of the test pieces and a button to take the player back. I then binded the scene changer script to the button and made it so it would take the player back to the main screen. I then went back to the main screen and then binded the scene changer to the ‘HELP’ button and made it take the player to the help screen.

After that I decided to create the player movement test piece and this was done by creating another new scene and adding a canvas with a plain background, a white block for a character, a black block for the floor and 3 transparent blocks for the walls and the roof. I made it look like this rather than adding textures and that is because it was only the test pieces so I only needed to check if the code worked. I then also created box colliders on each of these objects but the background this is so the character would say in the area.

After this is I then went on to create the code for the character movement and this was done by adding a 2D rigidbody to the character so this would give it the physics that it needed. I then added a jump force and a walk force public integers and then created a public boolean that checked if the player was on the ground. I then made it so when it started it took the rigidbody component and applied it in game. After this I created a public void update and in here I put the movement function which I chose force, this is because I needed force to act upon the character. I then went and coded lines where it would detect if the character was grounded and this was done by setting the platform as the ground and when he was on it, it counted as true and when he wasn’t it counted as false. After this I then coded the movements and this was done by setting the input key for jumping as ‘W’ and it would only work when the player was grounded, I also then made it debug the jump every time it was pressed and this is because I was having slight bugs with it. I then went on to doing the left and right and this was done by adding force on the character so it moved left when the ‘A’ key was pressed and it would move right when the ‘S’ key is being pressed.


I then went on to create the pause menu in game and this was done by creating a new canvas and putting a black background on it with the opacity turned down a little bit. I also then went and added a text that said ‘PAUSED’ as well as 2 buttons one was the resume button and the other was the exit button. I then decided to bind the scene changer code to the exit button and set it to take you back to the home screen. I did this so when it comes to creating the pause menu for a game I know that it works.

I then went and created the script for the pause menu and this was done by creating a public boolean to check if the game is paused and I set it only for the pause menu canvas. After this I then created a void update to detect is the ‘Escape’ key has been pressed and if it has it would pause/unpause the game, I set it so if the game was paused then it would set the game at 0 times the speed and if it wasn’t then it would play at normal speed. I then coded the resume button so if it was clicked it would unpause the game.

