Building Sprite-Based Games in ReactJS
Andrew McPherson
Web/Game Developer
Seattle, Washington
I talk really really fast.
I
I
I
I make sprite-based games
What is a "sprite?"
Rendering the sprites
Over and over
again... at 60 fps?!
Any mis-optimization
causes "screen tearing"
Our current model is
very "mono-directional"
There has to
be a better way!!
React
for rendering
sprites as DOM
DOM for DOMmies!
Rendering JSX into the DOM
Defining a class
Reusing that class
Adding properties
Rendering CSS into the DOM
"Absolutely" positioning the CSS
Dynamically positioning the CSS
Adding a loop
Adding a state
Manipulating the state
Handling collision
Moving diagonally
Randomizing positions
Coloring everything
Recording the score
Displaying the score
Decorating the score
Defining the paddles
Adding the paddles
Moving the paddles
Colliding with the paddles
Tada! "Ponk!"
The DOM is fast
Using the VirtualDOM in React
The DOM is hierarchical
For cameras and ragdolls and more
The DOM is responsive
Using Media Queries, Viewports, and SVGs
(this is my spritesheet)
Rendering an SVG spritesheet
The DOM is animated
Using Keyframes and Transitions
The DOM is devfriendly
Through Webtools and Jest
React is awesome for rendering stuff. :]
In Conclusion
Thank you so much for listening to me ramble on and on!! Any questions?