How to Make a Game With React

Rate this content
Bookmark

We make websites with React. We make apps with React. But how do we make games with React? In this presentation I will build up show you how to build up a React game engine tecstack using Poimandres libraries, explain the core concepts and, yes, even build a game.

This talk has been presented at React Summit US 2024, check out the latest edition of this React Conference.

FAQ

The key components used are React 3 Fiber, which allows for declarative building of 3D scenes in React, and Cota, a state management library efficient for updating high volumes of data quickly. The development also employs tools like Triplex for a visual IDE experience.

Entities in the game are managed using traits and behaviors. Traits hold data and define entity characteristics, while behaviors are small, composable functions that dictate entity actions, updated every frame using a central frame loop. This setup allows for dynamic and interactive game environments.

Triplex provides a visual IDE that helps developers move and arrange elements within the 3D environment visually. It aids in saving configurations back to the code, enhancing the development workflow by providing a more intuitive interface for managing 3D objects.

Yes, the approach can be adapted for React Native since the state library Cota is agnostic and can be used with vanilla JavaScript or React Native. However, it may not be as fast on React Native due to limitations like the absence of JIT (Just-In-Time) compilation on Apple devices.

Composable behaviors allow for modular and manageable game logic, where each behavior represents a small, independent function that can be combined to create complex interactions. This modularity facilitates easier debugging and iteration, making it easier to refine and expand game functionality.

The purpose of using React for game development is to leverage the tools and knowledge that web developers already have, making it easier to bring game development to a wider audience without having to learn new programming languages like C# or C++. React allows for quick iteration of ideas, which is a significant advantage in game development.

Cota is a state management solution designed to efficiently update high volumes of data quickly. It acts as a local database that integrates with React to manage the dynamic and high-frequency updates required in game development, supporting thousands of objects and a dynamic structure.

React 3 Fiber allows developers to build 3D scenes declaratively in React, similar to how DOM elements are managed. It integrates fully with HTML and the React ecosystem, enabling the use of familiar tools and libraries in a 3D environment. It is powered by 3JS, providing robust 3D capabilities.

Kristopher  Baumgartner
Kristopher Baumgartner
22 min
19 Nov, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
I'm here with the Poimandris Open Source Dev Collective, and I'm going to show you how to make a game with React using patterns you know and probably a lot you don't. We'll use React, React 3 Fiber, Kota, and Triplex. Cota is a nimble state solution that creates a local database for efficient updates. Spawn entities with specific traits and update them accordingly. Learn about composable behavior in Kota and how to update entities every frame. Enhance the visual appearance of the game by adding a HiFi view, materials, lights, and post-processing for bloom. Understand the concepts of creating games in React, dynamically spawning entities, and giving them behavior. Learn about testing strategy, compatibility with React Native, and the advantages of using React for game development, including wider accessibility and quicker iteration.
Available in Español: How to Make a Game With React
Video transcription and chapters available for users with access.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

The Whimsical Potential of JavaScript Frameworks
React Summit US 2023React Summit US 2023
28 min
The Whimsical Potential of JavaScript Frameworks
Top Content
Watch video: The Whimsical Potential of JavaScript Frameworks
The speaker discusses the whimsical and detailed work of Stripe, particularly their interactive and dynamic pages. They explain the use of React for building whimsical details and tracking mouse position. The speaker introduces React Spring for smooth animation and React3 Fiber for creating a 3D egg model. They also mention the use of Framer Motion and React server components for animating CSS properties.
Emotional & Functional UI Animations in React
React Day Berlin 2022React Day Berlin 2022
28 min
Emotional & Functional UI Animations in React
Today's Talk discussed the importance of UI animations in React, both functional and emotional. Examples were given using CSS and Framer Motion, with a focus on user feedback and accessibility. Design guidelines and animation usage were highlighted, as well as the consideration of negative emotions in animations. The Talk also touched on designing 404 error pages and concluded with gratitude to the audience and organizers.
JavaScript Haikus: My Adventures in Tiny Coding
JS GameDev Summit 2023JS GameDev Summit 2023
27 min
JavaScript Haikus: My Adventures in Tiny Coding
This Talk is about writing super tiny JavaScript programs, known as tiny code. It explores the concept of code golf and the use of a live editor for instant feedback. The Talk discusses various ways to share tiny code, including Twitter.net. It also covers creating graphics, games, and sound in a small space. The speaker highlights inspiring tweets and showcases examples of tiny code, including asemic writing. The future of tiny code includes new techniques, better browser support, and AI-assisted programming.
Hacking an e-Reader with React
React Advanced 2023React Advanced 2023
7 min
Hacking an e-Reader with React
Watch video: Hacking an e-Reader with React
React for eBooks? Learn how to hack an eReader to display a tea menu. Create images and write e-books using React. Use EPUB format to create chapters and include CSS. Use Pandoc and Dino to simplify the process and make quick updates.
Hacking an e-Reader to Show My Tea Menu With JSX
React Day Berlin 2023React Day Berlin 2023
7 min
Hacking an e-Reader to Show My Tea Menu With JSX
Watch video: Hacking an e-Reader to Show My Tea Menu With JSX
React can be used to create custom menus for e-readers, and the process involves creating an image and e-book with React and loading them onto the e-reader. Writing an EPUB e-book for e-readers involves converting an SVG file into a PNG image and writing the e-book in EPUB format using HTML, CSS, and images. EPUB generators like Pandoc and Dino simplify the process of generating EPUBs from markdown and running JavaScript on the desktop, respectively.