React js For Games

About Me

Full stack develolper

Fiddle with Js

I Like to 

Sr. Software Engineer @ Snapwiz. Inc.,

Amateur Harmonica Player

@NagarajanFs

 

Tell others what to do

What we are talking about

Not this

Frameworks & React js

  • Frameworks/Libraries are , code written by others for common purposes
  • Frameworks have to be flexible 
  • They have to abstract tedious repetitive tasks away from developers
  • React js does these things declarative
  • Only need to say what needs to happen (not how)

Declarative Games

  • Why  can't we have same declarative way of coding for Games
  • You lose control with declarative
  • You trade-off some performance with declarative systems 
  • For a game , you need to update the screen with about 40-60 fps without any stutter for good experience
  • That means within 16-25 ms is all you have for each frame

React Js reconciliation

  • Fast enough for normal UI applications
  • Not fast enough for games

react-dom-box2d library

  • By making use of react low level integrations, I created a library
  • Purpose of this library to use react & declarative way to write simple games
  • Library provides box2d physics library for your react  elements (specifically react-dom)

Box2d is a physics engine for 2d games

What about canvas/webgl

Canvas webgl will make proper use of  GPU

Thats why, I have been working on similar idea using Pixi.js

Writing Games with React

By Nagarajan N

Writing Games with React

  • 57