Category Archives: Javascript

P5JS

I have been experimenting with the P5JS library.  P5JS is an open source JavaScript library for creative coding.  It can be found here:

P5JS provides easy to use functions for graphics, sound and user input.

P5JS Harmonic Motion

The Nature of Code

I have been working through The Nature of Code by Daniel Shiffman. It provides a great introduction to techniques for real-time simulations and animations. The full text of the book is available for free here:

https://natureofcode.com/book/

The author hosts a YouTube channel with an enormous amount of educational content for creative coding:

https://www.youtube.com/user/shiffman

Here’s a randomly selected video I found interesting:

In fact it inspired me to make my own image:

 

Collatz Conjecture Context Free Art

My JavaScript Sketchbook

I have been collecting the JavaScript sketches that I have made here:

https://goshdarngames.com/js_sketches/

Sketches are quickly hacked together projects to learn a technique or library. It’s a lot of fun to work on small projects like these and some of the have turned out to be rather fun to play with as well.

This video shows a sketch I made exploring Simple Harmonic Motion.

P5JS Harmonic Motion

There are lots of fun JavaScript libraries I am eager to play with. E.g.

There are lots of exciting things to explore with JavaScript.

Namespaces and classes in Javascript

I am currently working on a game for Air Console. It’s a cool platform for local multiplayer web games.

So far most of my time has been spent experimenting with HTML5 game frameworks. For this project I have settled on the CreateJS suite. It seems to be functional, minimal and up to date.

I have also been learning a bit more about how to organize a HTML/javascript application. Javascript doesn’t have special keywords for ‘class’ or ‘namespace’. Everything is done using functions, which left me scratching my head and wondering how you’re supposed to manage a large codebase without constantly running into name conflicts.

There were two articles I found helpful. The first is a simple rundown of some common ways to use Javascript’s functions like a class:

http://www.phpied.com/3-ways-to-define-a-javascript-class/

The second article explains a slightly more complex concept that allows you to create namespaces within Javascript. This allows you to encapsulate all the variables in your app within a single root var, which helps reduce the chance that one of your variables is defined in another module.

https://appendto.com/2010/10/how-good-c-habits-can-encourage-bad-javascript-habits-part-1/

The article features my new favourite piece of technical jargon: Self-executing anonymous function. It’s a phrase that would strike terror in a student’s heart if it appeared at the top of a lecture slide.