Around JavaScript, node.js, WebGL and cool HTML5 game stuff

Last week we started talking about
webaudiox.
In this
first post,
we talked about the project and started to explain the helpers webaudiox.shim.js
and webaudiox.loadbuffer.js.
This week we are gonna focus on webaudiox.jsfx.js.
This helper provides you an easy way to use
jsfx.js
with your Web Audio API games.

Webaudiox.js
is a bunch of helpers for
WebAudio API.
I wrote them a while back.
Now I would like to make a series of posts about it. This post is the first.
I plan to publish one post per week explaining WebAudiox the marvels you can do with WebAudio API.
I hope we will enjoy yourselves in the process :)

This post is about detecting global variables in javascript and eradicating them :)
This is a first post about debug.js,
a library to make javascript easier to debug.
Global Detection is one of the features of this library.
I came up with the idea back in May 2012 at
Web Rebels at Oslo.
So i was quite enthusiatic and started coding right away on the plane back home.
Now, debug.js has quite a bit of features.
In future posts, we will detail them and explain how they can be useful in your own code.

This is post presents assertWhichStop.js.
assertWhichStop.js
is a simple library which provide an assert() which stops…
who would have guessed :)
You may find that surprising but in your browser,
javascript’s
assert()
does not stop the execution of the code but it does in other languages.
assertWhichStop.js
will make your assert stop even in your browser.

assertWhichStop.js
is a part of
debug.js library,
which we talked about in previous posts.
This post will explain why it is usefull to stop and how to use assertWhichStop.js.
This library is
very small
, barely 10 lines full total at the time of writing.
It is based on a little
gist
we did in collaboration with
jens arp.
Ok now let’s see more deeply what is assert.

console4Worker is console API for WebWorkers.
WebWorkers are hard to debug. On top of that, console API
is unavailable
in WebWorkers. It doesn’t help.

console4Worker
is a simple library which tries to fill this gap.
It provides the console API
, the same api you are used to.
It implemented in most browser, node.js, even part of
commonjs.
See the demo
in the examples/ directory.

On the Worker Side

First you include the script with this line.

1

importScripts('console4Worker-worker.js');

And you are done! Now you can console API as you would normally do, even if you are in a
webworker.
Lets say something like

Pacmaze just got an update.
it was long overdue, i admit, other matters distracted me from it.
It is good to be back on it tho.
It is version 5 now. It is a major performance update, 5 time faster in some cases.
The game is now embeddable in external pages.
Additionnaly, Packy has been renamed Pucky as a reference to the original name of pacman,
‘Puck-Man’.
You can read all about the history of pacman in the pacman dossier.

Embedded game

microcache.js is a micro library to handle in-memory cache. It is less than
20 lines and works in node and browser.
It is available on github here
under MIT license.
If you hit bugs, fill issues on github. Feel free to fork, modify and have fun with it :)

GoWithTheFlow.js is a javascript asynchronous flow-control micro library which works in
node.js and in browser. It allow to control how your
asynchronous code is executed, sequentially or in parallel.
Flow() is only 30lines.

How to use it

Let start with a basic example. 2 jobs run in sequence. The first job is a timeout
so the result is delivered asynchronously, and a second job is run only after the
completion of the first.

123456789

Flow().seq(function(next){console.log("step 1: started, it will last 1sec");setTimeout(function(){console.log("step 1: 1sec expired. Step 1 completed");next();},1000);}).seq(function(next){console.log("step 2: run after step1 has been completed");})

It will display the following

step 1: started, it will last 1sec
step 1: 1sec expired. Step 1 completed
step 2: run after step1 has been completed