Endless Runner Game

Runner Game Screenshot

Overview

This Java desktop application is a 2D "runner" style game that is heavily inspired by Flappy Bird.

Motivation

Flappy Bird is a game I've always been fascinated with. "Runner" style games seem simple, but I knew implementing a 2D game in Java for the first was going to a good challenge. However, I wanted to know how to make a simple game that I could show to my friends.

Implementation Process

Since this was the first time I planned on coding a 2D game, I started out by following a helpful tutorial that explained the basics to get core part of the game running. There were a few concepts that I was familiar with from school, such as ArrayLists and random number generations. However, rendering graphics on a JFrame was a bit tricky at first.

After I had implemented the core functionalities, I thought about how to make the game better. In my opinion, it needed better visuals to immerse the user. Thus, I ventured into adding images for the bird, the background, and some trees. I found the images on a royalty free image website https://pixabay.com/.

To add depth to the background, I implemented a motion technique for the trees based on their size. By assuming all the trees are roughly the same size in this world, bigger trees would suggest that they closer to the foreground. Since they are closer, they should move faster across the screen. This is easier to understand if you think about looking to the side of the road when you are in a moving car. Objects in the environment that are closer to you fly by the fastest. However, objects in the distance, such as mountains or buildings, move slower. In other words, they stay in your frame of sight for longer.

Later, I realized that the game still wouldn't be immersing without sound. So, I created some of my own sounds, and found a couple royalty free ones online. While reading Java documentation for loading and playing sounds, I realized there were multiple packages to choose from. The difference between them wasn't clear to me at first, so I chose one that sounded like it was fit for my needs. However, the sound only played one time. I needed it to play many times for the flapping of the bird's wings. After browsing the web for additional help, I discovered that sounds had to be stored as a Clip object. After following this advice, the sounds could be played repeatedly.

Technologies Used

  • Java
  • GitHub

Try It

Click the button below to download and play the game.
* Requires Java Runtime Environment to be installed.




View the Source Code on GitHub

GitHub