Ready Player React: How to Build a Video Game With JavaScript — Part 3

Jawara Gordon
5 min readFeb 11, 2024

--

It’s time for the penultimate episode of “Ready Player React: How to Build a Video Game with JavaScript” — Testing!

Before moving on, let’s reflect on our journey so far. In part one, we tackled the essentials of game planning like choosing our game loop and hook. Then, in part two, we set up our environment, inserted game logic using test-driven development, and tackled the challenge of using audio in the browser.

Now, let’s shift our focus to “Testing” — a critical phase where we playtest our game from beginning to end, gather feedback from beta testers, fix bugs, improve performance, and optimize our build for the final phase — deployment!

Playtesting

Let’s talk about an important stage of the game development process: playtesting. Playtesting is when developers and QA engineers rigorously test the game to find problems and fix bugs. This ensures that the game mechanics work as intended for as many players, in as many scenarios as possible.

Think of this phase as an opportunity to see how your game holds up under pressure — it’s a heat check to gather critical insights, catch edge cases, and build a final game that can hold its own in a production environment.

Here are some tips to get the most from playtesting:

  • Player Selection: Find players from all walks of life to test your game. Find the youngest and oldest people you know and ask them to provide feedback using a friction log.
  • Observations: Watch beta testers play your game without stopping them or interfering in any way. Allow them to give honest feedback on where they encounter difficulties or enjoyment.
  • Bug Fixes: Use feedback to make iterative bug fixes, logging each change with detailed notes and commits.

Effective playtesting transforms frustrating bugs and errors into a fine-tuned experience that players will want to replay again and again! It’s important to iron out any issues now before trying (and failing) to deploy.

Performance

The next crucial step is enhancing our game’s performance. This involves code splitting, refactoring, and managing state to reduce complexity and improve responsiveness. A great place to get started is by caching game assets to reduce load times. Then you should remove any unused dependencies that may bloat your bundled game file.

You can get started with code-splitting by doing the following:

  • Use React.lazy to dynamically import components that are loaded only when they are needed.
  • Employ Suspense to display fallback content while your components are being loaded, like thumbnails and spinners.
  • Structure routes to dynamically load components at the route level, optimizing faster load times.

!important: Don’t forget to run the testing suites we created eariler while making any changes to the codebase.

This is where that safety net we created comes into play. We can catch bugs and issues immediately by keeping a careful eye on our unit tests. This approach not only streamlines the development process but also significantly enhances the maintainability and quality of the code as you introduce more features down the road.

Pre-Deployment

This is it! We have a finished game that’s ready to make its big debut! We only have one phase left to go — deployment. But how do we get it out of our computer and into the hands of other players?

Bundling

The process of compiling and combining various files and assets of an application together is called bundling. This is crucial for optimizing performance by reducing the number of requests needed when loading the game. Tools like Webpack or Parcel analyze your project’s dependencies, re-package, and minify your JS, CSS, and other assets into small, fast-loading files.

Note: Create React App (CRA) utilizes Webpack under the hood for bundling. Webpack automatically compiles and bundles all JavaScript, CSS, and asset files into efficient static files ready for production.

The npm run build command is what initiates the process of taking our game from dev mode to production mode. When you execute this command it triggers the creation of a build folder, compiling your app into static files optimized for production transforming your dynamic, development-stage project into a fast-loading package suitable for deployment on your favorite platform.

As we wrap up this chapter, we’ve fully optimized our game and we’re almost at the finish line. In the final phase, we’ll deploy our game and prepare for future updates and features.

Make sure to subscribe and follow to get notified about the last installment of “Ready Player React,” along with more of my insights on coding, mindfulness, and project management.

Sources

Resources:

--

--

Jawara Gordon

Jawara (jah-WAH-rah): Full-Stack Web Developer | Audio Engineer JavaScript, React, HTML, CSS/SASS, Ruby on Rails | Ableton Live