project cover

Introduction

01

For my final project in the Stanford Code in Place course, I decided to recreate the classic Google Chrome Dino game with a unique twist. The game is dedicated to my dog, Alex, whose birthday coincided with the project's final deadline. To celebrate, I themed the game around her birthday party. This article outlines the step-by-step process of developing the game, focusing on the game mechanics, animation, and design choices.

Creating the Canvas

01

The first step was to set up the canvas using the Stanford Graphics library. This canvas served as the playground for all game elements.

project cover

I defined the canvas dimensions and some constants to control the game's obstacle velocity and frame delay.

Initializing the Canvas and Background

03
project cover

Here, I initialized the canvas and set up the background image. The bg_x variable is used to move the background, creating the illusion of a moving scene.

Game Mechanics

04

Obstacles and Character Initialization

04.01
project cover

I initialized the obstacles and the main character, Alex, with initial positions. Alex has three images to create a simple running animation.

Handling the Game Start

04.02
project cover

The game starts when the player presses the space bar. Until then, a welcome message and instructions are displayed.

Animation and Background Movement

05

Animating the Main Character

05.01
project cover

The background moves to the left, giving the illusion of Alex running. The background image is designed to loop seamlessly, resetting its position when it moves off-screen.

Jump Mechanics

06

Handling the Jump

06.01
project cover

The jump is controlled by monitoring the space bar key press. If Alex is already jumping, the handle_jump function manages the upward and downward movement:

project cover

Collision Detection

07

Checking for Collisions

07.01
project cover

Collisions are detected by checking the distance between Alex and each obstacle. If a collision is detected, the game ends with a "GAME OVER" message.

project cover

Design and Art

I created pixel art for the game using Procreate. This included Alex, the obstacles, and the background. The obstacles are geese in party hats, a nod to Alex's love for geese and the birthday party theme.

Conclusion

Developing this game was a rewarding experience that combined programming skills with creative design. The birthday theme added a personal touch, making it a special project dedicated to my dog, Alex. Through this project, I learned how to handle game mechanics, animation, and graphics within the constraints of the Stanford Graphics library.

Back to Homepage