Try it now => https://a-hamouda.github.io/go_gary/
**Known limitations: Running p5js on Safari has unpredictable results.
Garold "Gary" Wilson, Jr. is SpongeBob SquarePants' pet sea snail and the most seen pet in the series. He lives with SpongeBob in his pineapple house on 124 Conch Street. (reference).
Gary lives in Bikini Bottom, which is the main setting in the SpongeBob SquarePants series. It is an undersea city where SpongeBob and his friends live. (reference).
Go Gary is a game where Gary tries to eat food and avoids eating rotten food, and falling into manholes.
Initially I used javascript
, but after the midterm submission the code was missy and full of bugs mainly because I
couldn't ensure type-safety of objects, so I rewrote a big part of the project in typescript
to overcome the
previously mentioned obstacle, and to safely implement Object-Oriented Programming.
The game rely on the p5js
library for manipulating the canvas.
I used Git
VSC to manage the creation of every feature and to maintain a working version on the master
branch.
- MVC pattern: To satisfy the SOLID principles.
- Random scenery: The creation of scenery objects is completely random. Once the page is reloaded, the scene will be changed.
- 2d perspective : All Scenery objects move in different speeds based on their distance from the scene camera.
- Buffered renderer: To avoid off-screen drawing and improve the game performance.
- Full-Screen mode: The game scene takes all the window size. (A page reload might be required to adapt the window size)
- Pixel density slider: When in fullscreen mode, the game lags on retina displays due to heavy graphics, but the pixel density can be changed using the top right slider to allow for smother experience.
- Singleton pattern: Implemented for views and controllers.
- Strategy pattern: Implemented for most of the models.
- Clean code: Almost all the classes in the project follow the same pattern. I also strove to give meaningful names to variables and functions.
- Font and sounds are loaded inside
preload()
. - Pixel density slider is created inside
setup()
. - Scenery objects "views" singletons are created once and drawn inside
draw()
. - An instance of
Animator
is created once, and then animation logic is called.
- Holds static default values such as default sizes and colors.
- Has a constructor to create objects.
- Extends
MovableSceneryModel
. (Exceptions: sky rays models and ground models)
- Singleton class.
- Generates random models.
- Responsible for changing the underlying values of models.
- Responsible for storing models.
- Extends
MovableSceneryModelsController<T>
. (Exceptions: sky rays controller and ground controller)
- scenery object
- Singleton class.
- Knows the drawing area of models.
- Calls the corresponding
controller
to generatemodel
s inside the private constructor. - Calls
p5js
framework specific commands. - Does the actual drawing of the objects for each
model
.
- animator
- Singleton class.
- Listens for, and responds to user key-presses.
- Verifies game logic by checking for game over status.
- Forces gravity on character.
- Animates food movement.
- Checks and responds to food collection.
- Checks and responds to character falling into manhole behavior.
- Animates scary eyes inside the manhole.
- Resets the game when the user wants to play again.
- buffered renderer
- Singleton class.
- Exposes a generic method that returns only the models currently in the screen bounds plus a small buffer.
- sketch
- Fonts and sounds are loaded inside
preload()
. - Pixel density slider is created inside
setup()
. - Scenery objects "views" singletons are created once and drawn inside
draw()
. - An instance of
Animator
is created once, and then animation logic is called.
- Fonts and sounds are loaded inside