Genius Hour:

Programming

Table of Contents

Week One: Introduction


     Hello! My name is Amogh Patnaik and I go to 212 Academy. This year, my class is participating in Genius Hour. This blog will showcase my research and learning on a topic that I chose. I chose to study about programming because I like to code, and you can make anything you want to make if you put the time into it.

     I will use the Unity game engine to create a ping pong game (pong), which will be my final product. This game will showcase all the skills I have learned through my research. A game engine is a tool or app that makes it easier to create a game, using mini tools such as player movement and animations. Unity is a very popular game engine that many programmers use to create both 2D and 3D games, and it has many tools and templates to help you do this. I will present my game on the web using WebGL technology. I have 3 inquiry-based questions that I want to find the answer to. The first question I asked myself is "How do I make a GUI?" This means making a main menu for a game. The second question was "How do I make an AI bot to play against the player in 1-player mode?" Finally, I asked, "How do I publish my game to different platforms like Windows and Mac."
TROUBLE LOADING IMAGE

Week Two: Research

     This week, I used my basic knowledge of 2d physics to create a very simple ping pong game to test out the theory. In the process, I learned about Vector3 objects, which store a 3d position in a number. This is because Unity internally converts all projects, even 2d projects, to a 3d simulation. According to Unity's Official Documentation, this means that all positions and rotations have to be stored and manipulated using 3d physics. I used Vector3 objects to change the position of the player's paddle in one axis only. Then to simulate a bouncing ball, I researched how to make a circle (the ball) bounce forever. For this, I learnt about the Vector3.addForce() command. Using this command, You could push the ball in a direction forever by specifying the rotation of the push and the intensity of the push. When that got working, I then duplicated the paddle and moved it to the other side, as well as giving it different controls. This would be player 2. Then I created my main menu after researching how buttons work and how they are used. I also wanted to create a 3 player version of ping pong, so I tried to visualize this setup in the picture below.
As you can see, 2 paddles would be angled so that they are equally spaced from each other and the 3rd paddle, which is horizontal. To make the paddles be angled and also move at an angle, I would need to learn about Unity's way of rotating objects in 3d space, because Unity stores everything in 3d. According to Unity's Documentation , Unity stores 3d rotations as quaternions, but they are displayed in the editor as Euler angles because this method of displaying angles in 3d is easier to understand. Euler angles use 3 axes of rotation, x, y, and z. These combined with give a rotation in 3d space. I also learnt how to 'pause' the game using one command: time.timescale = 0; Next week, I hope to add an options menu too, as well as exploring ways of how to display scores for players.

Week Three: Research

This week, I started by researching ways to make a text gameObject, or sprite that changes dynamically with changes in different players' scores. To make this score display, I needed to initialize 2 variables for player1 and player2 scores and set them to 0. Inside the update function, which is called once per frame, I had the game check for when the ball collided with the players' goals on either side and increase the score of the opposing player when a collision occurred. I used this code to check for collisions and attached it to the left wall:

private void OnCollisionEnter2D (Collision2D collision)
{
    player2Score++;
}

To create the score display on the screen, I used the code: public Text Scoreboard; This created a text sprite named Scoreboard that was public, meaning it could be referenced by other scripts. Next, in an empty sprite, I added the line of code that allowed the game to update the scoreboard text with the players' scores. This was: Scoreboard.text = player1Score.ToString() + " - " + player2Score.ToString(); After that, the scoreboard system was working, so I moved on to other parts of the game. I researched ways to publish my game to the web using a simple process. I discovered that Unity Connect is a site that hosts web-based unity projects that people have published and the process to publish a project is simple and free. Unfortunately, by then I had run out of time to research, so I decided to continue my research on Unity Connect next week.


Week Four: Research

This week, I continued my research on Unity Connect, and I wanted to get comfortable with the process  of uploading  a unity project, so I created a new empty Unity project, and downloaded the WebGL package to enable WebGL for my game/project. Then, I followed the instructions given to me by the website, and uploaded my project to Unity Connect as well as sharing it with the world. You can see the test project here as long as you are not using chrome:
After uploading my test project, I was going to create an options menu in the main menu. To do this, I watched a YouTube tutorial that showed me how to create panels that deactivate and activate to switch between main menu and options menu and that has switches that change the graphics of the game. Here is the video:
After that, I had ran out of time for that week, so I wrapped up my project and saved it for next time. Next week, I hope to start finding and fixing bugs in my game that could affect gameplay or graphics.

Week Five: Presentation

This week, I started Unity and saw this when trying to play test the project:
My Unity project files were corrupted. I tried to recover my lost code but in the end, I couldn't get the code back, and I lost the options menu and 1 player game mode. I then decided to leave out the options menu for now, since I didn't really need it for the game to work, and I had to leave the 1 player game code for later because this week's goal was to start work on the presentation for my TED talk. I wanted to use Google Slides because I was familiar with it, so I created a new google slides presentation and started my work. I chose to use 1 slide for 1 week, and in each slide, I summarized my experience with lots of images contributing to the visuals of the slides. I finished the introduction by the time I had to stop. Next week, I hope to finish 4-5 more slides and write my script.

Week Six: Presentation

This week, I started by going right into creating my dialogue for the presentation and further developing my google slides for weeks 2-4 and further on.  Then I remade the 1-player mode and made the enemy bot easier to beat. I also uploaded my final unity game to unity connect but I had a problem. The game that was published was too small of a window to properly show everything in the game. The sides of the screen were cut off and the top was too short. I searched up many different wordings of my problem until I found out that the aspect ratio was wrong. The aspect ratio is the ratio of the screen width to screen height. It is found by dividing width by height. My aspect ratio was too small so i tried to increase it but Unity Connect did not offer an option for increasing aspect ratio of the game, only the screen. Just then I remembered about another game publishing tool called itch.io, in which I already had an account. I changed the aspect ratio there and successfully uploaded my project. It is now downloadable at https://spaceshark123.itch.io/pong-1 . After that was sorted I chose to include this setback in my slides and so I did. I also added a part about the advantage of NTI days which gave me more time to work on my project. This, although it was a disadvantage for some people, was a positive for me. I finished my speech and slides and rehearsed my lines 3 times. Then, I thought of answers for common questions people might ask me. Then, that was it, and I was finally ready and prepared.

Week Seven: Showtime!


This week, I recorded my TED talk and posted it to youtube so people can see it. I think I did well at talking loudly and clearly, though the audio quality of my recorder made it sound bad. I also think I did well on explaining my process and setbacks as well as showing all the features of my game. If I had the opportunity to deliver my TED talk again, I would talk slower, and try to improve the audio and video quality before recording. What I liked most about Genius Hour is that you can choose to learn about whatever you want, instead of having to choose from pre-made topics. The most challenging part about Genius Hour was that you have a time limit, so even if you have lots of setbacks, you still somehow have to catch up so you finish in the deadline. As I said in my presentation, in the future, I hope to further work on and expand my game by adding features like online multiplayer, a stable fps, and by remaking my options menu and 4-player mode. I don't have any more doubt about the Unity Game Engine like I did before, and I hope that I keep learning about Unity in the future.

Downloads

To download Unity Game Engine and start developing for yourself, click the following link to go to the Unity website. Then click Get Started and click the "individual" tab. After that, select the personal version of Unity and download it there.

Click to go to Unity Website


To download and play my finished game, click the following link to go to the website where you can download it. Click the download link for your operating system, windows, mac, or linux, and follow the instructions on the page to play the game. Remember: I am always updating the game, so make sure you visit periodically to get the latest version. Have Fun!

Click to go to Download Page for my Game