part-shop
A DIY Custom WebWorker Game Library
The goal of part-shop
is to create your own perfromant Game
components called Middleware
s, and data silos called Part
s that manage game objects.
For now, it requires the use of webpack
or browserify
to create bundles that run in both a browser and inside a web worker.
For example, using webpack
, bundle your application, and in part-shop
's Game
configuration, point it at itself. Using path/to/bundle.js
...
//Only one js file means faster loading and it runs in both the worker/browser let g = middleware: require parts: require game: index: parts: 'hello-world' middleware: 'simple-physics' initialState: 'index' worker: 'path/to/bundle.js';
Middlware
Middleware
ask Parts
for data and control when the application draws things.
For example a canvas middleware might look something like this:
//File: ./middleware/canvas.js; let c = document;let parent = document;let context = c;parent;parentstylemargin = '0 auto'; let mousePosition = x: 0 y: 0 ;let { let rect = c; mousePositionx = eclientX - rectleft; mousePositiony = eclientY - recttop;};c; static { let { ; game; }; documentbody; cwidth = configcanvaswidth; cheight = configcanvasheight; } { super; } { datamousePosition = mousePosition; } { forlet i = 0; i < thispartslength; i++ thispartsi; }