Side Scroller Video Game

The Game

The game is simple. You are a pterodactyl that is trying to avoid the flying meteors and get to safety on the other side. You start on the left and you move up and down while progressing right until you reach the end of the screen. Once you touch the end you win.

This game was created as a final project for CSS 101, Digital Thinking. I wanted to create a game that was entertaining to play yet challenged my thinking in coding and with my skillset at the time. Therefore, I made a side-scroller game where you dodge obstacles. This game was inspired by the popular flash game, Dino Run. I use a program called Processing and coded with Java to create this project.

Player Mechanics

The first step was to code was player movement. I needed to figure out how to make the player move in a way that felt natural and the character had some weight to it. Originally, I had the character move in a consistent pattern when pressing any of the arrow keys. The problem with this was that player movement felt unnatural and the player would float in space.

Player movement during its first stages of development

Because of how first the iteration felt, I decided to code player gravity in by having the player constantly move down towards the bottom of the screen. With gravity added, the sprite the player controlled felt like it had weight, feeling more natural.

Player movement. The player is able to move the sprite up, down, left, and right

With this code, the player is able to move in all four directions using the arrow keys on a keyboard. The code (keyPressed and keyReleased) detects whenever the player presses an arrow key and converts that to movement. The code (control and move) detects those key presses and converts them into values. These values add or subtract from the players X and Y axis, allowing movement in the direction based off which arrow key is pressed.

Code to calculate movement when arrow keys are pressed
Code to detect when arrow keys are pressed

Obstacle Mechanics

The obstacles are randomly generated and move at a constant speed from right to left. If the player touches these obstacles, the game automatically reset and the player is placed back at the beginning. This mechanic is the essence of the game; dodging and moving around the randomly generated obstacles until you reach the end.

The obstacles you need to avoid in order to not lose the game. Moving right to left in a random order

The code here explains how the obstacles are generated, the speed they move at, what happens when the player touches one of these obstacles, and how often these obstacles appear.

Code that controls the speed and the random of the obstacles. Also detects when player touches one of these obstacles and makes the game end.


The theme of the game is inspired by Dino Run. Dino Run has a pixel art style where the dinosaur runs left to right avoiding meteors that fall down. My game is very similar, however you play as a pterodactyl and you fly around the sky avoiding meteor showers. The meteors fly towards you while the pterodactyl flies from the left side of the screen towards the right, then end goal.

Dino Run, primary source of inspiration for my game
Pterodactyl model. The player controls this model
The game background, purely aesthetic to fit the game’s theme
Volcano. Added to fit the theme of the game