A 2D cannon shooter game made with Unity in which the player must destroy balloons with cannonballs. This game was made as part of a course assignment for COMP 521 Modern Computer Games in fall 2020 at McGill University. The goal of the assignment was to implement Perlin noise, Verlet integration, physics, and collision detection manually, without the use of libraries.
No third-party assets are used in the game.
You can play the game on GitHub Pages HERE!
You must have Unity version 2019.4.9f1 installed on your computer. Other versions of Unity may have compatibility issues.
Clone the master branch of this repository with git clone --single-branch https://github.com/christopher-boustros/Unity-Cannon-Shooter-Game.git
, or alternatively, download and extract the ZIP archive of the master branch.
Open the Unity Hub, click on the Projects tab, click on the ADD button, and select the root directory of this repository.
Click on the project to open it in Unity.
In the Project window, double click on the MainScene.unity
file from the Assets/Scenes
folder to replace the sample scene.
Click on the play button to play the game.
Up arrow = move cannon barrel upwards
Down arrow = move cannon barrel downwards
Left arrow = decrease muzzle velocity
Right arrow = increase muzzle velocity
Space bar = shoot a cannonball
Tab key = switch cannons
The detail on the surface of the ground and water is randomly generated one-dimensional Perlin noise. The benefit of generating height values using Perlin noise instead of pseudo or true-random numbers is that each Perlin noise value is close to its previous value, making the terrain look smooth and continuous.
The motion of a balloon's body and string is modelled using Verlet integration and constraints between points. With Verlet integration, the previous position of a point on the balloon is used to determine its current position, allowing for a realistic-looking 2D simulation of movement.
Cannonballs bounce upon collision with the ground and disappear upon collision with the water. When a cannonball hits a balloon body, the balloon disappears, and when a cannonball hits a balloon string, the string moves such that it does not intersect with the cannonball.
There is wind which changes velocity every 2 seconds. The balloons move in the direction of the wind and are destroyed when they move off screen.
-
The implementation of the
UpdateOrthographicCameraSize
method inCameraScaler.cs
is inspired by this source. -
The implementation of the
ApplyVerletIntegration
andApplyStringSegmentLengthConstraint
methods inVerletBalloon.cs
is inspired by this source. -
The method of implementing a Perlin noise function in
PerlinNoise.cs
is based on this source. -
The method of implementing procedural terrain generation in
ProceduralTerrainGeneration.cs
is based on this source.
No code in this repository is copied from the above sources.
This repository is released under the MIT License (see LICENSE).