top of page

Cubethon

Screen Shot 2018-09-27 at 8.48.50 PM_edi

Cubethon is game where the player (a cube) attempts to avoid a variety of obstacles. The player has a constant forward force, and is able to avoid obstacles by moving from side to side. The player can move to the left using the A-Key and the player can move to the left using the D-Key. On the third level, the player can jump over obstacles using the Space-Key. The level will reset to the beginning when the player hits or makes contact with an obstacles, falls off the side of the ground or if the player jumps too high on the third level. The goal of the game is to avoid all of the obstacles and reach the end goal, which will display an animation that the current level has been completed, and will take the player to the next level. Each level increases in difficulty, and once the third level has been completed, the player is taken to a credits menu which gives the option of returning to the main menu.

Cubethon Menu.png
On Click Action.png
Menu Script.png

The images above demonstrate the transition from the menu to the first level. The button which has the text "START" has an On Click action that runs the Menu.StartGame function. The code for Menu.StartGame is seen above. Scene Management was imported into Visual Code Studio, and the code above finds the buildIndex of the current scene, and then adds two to it in order to load the first level. The buildIndex was identified within the build settings in Unity. The buildIndex is increased by two because the next scene is the instructions menu, so in order to skip the instructions menu, two must be added to the buildIndex.

Player Movement.png
Movement Script.png
Player Movement Component.png

The images above demonstrate the movement of the cube. In order to cause the cube to move, a force was applied to the RigidBody of the cube. Multiple if statements were used to decide which direction the force should be applied, dependent on the key pressed. If the D key was pressed, a force would be applied in the positive x-direction and the cube would move to the right. If the A key was pressed, a force would be applied in the negative x-direction and the cube would move to the left. If the space-bar was pressed and the player was on the third level, a force would be applied in the positive y-direction and the player would jump.

Player Collision.png
Player Collision Component.png

The images to the right demonstrate collisions for the cube. A collider tag was applied to each of the obstacles on the course, and if the player had a collision with any of these obstacles, movement would be disabled, the GameManager would run the EndGame function. The EndGame function displays a Game Over message and restarts the level following a delay.

Collision Script.png
End Game Script.png
Score Text Script.png

The images to the left show the player's score being updated. After every frame, the update method is called, and in that method the player's position is transformed into a string and then scoreText is set to the string. The scoreText is part of the canvas and once connected to the script, automatically updates in game. 

Score Text Component.png
LevelComplete EndTrigger Component.png

The images to the left show the GameManager updating the game after a level has been beaten. When the player passes through the finish, OnTriggerEnter is called, which calls the CompleteLevel method in GameManager. This sets the completeLevelUI as active, causing it to appear on screen for a period of time before the next level is started.

GameManager Component.png
End Trigger Script.png
Complete Level Script.png
Load Next Level Script.png

This image shows the code used to load the next level once the finish line is passed for each level.

Level Complete Animator.png
Level Complete Animation.png

These images show the setup for the animation that displays when a level is completed.

Level Complete Image.png
bottom of page