felixangell / biodefence

biodefence
https://biodefence.netlify.com
1 stars 0 forks source link

game...

A nightly build of the master branch is deployed here

building

requirements

you'll need:

build & run

$ git clone http://github.com/felixangell/biodefence
$ cd biodefence/
$ yarn

watch

This will compile the javascript as you update it. So as you are you changing the code this will run in the background and compile any new changes. All you have to do is reload the web browser.

$ yarn d

If you open localhost:3000 in your browser the game should be running.

notes

Rendering via. the HTML5 canvas MatterJS Physics engine

Source files are in the src directory:

Entities in the physics engine are rendered from the centre? So we take off half the width andh eight from the x/y position when rendering.

game loop

There is a game loop in src/index.js, specifically the start method of the Game class. This sets up a loop that runs (hard coded) at 60 fps, i.e. 60 iterations a second. In this game loop, the update and render methods are invoked. The update method handles the animations, physics, and positions of entities, whereas the render method is in charge of rendering the objects and entities to the canvas via. the provided graphics context.

state system

For now a single game state is hard coded in as it's the only state that is necessary to focus on currently (GameState).