Posts Tagged ‘boilerplate’

p5.js experimentation/prep = code for all

Posted by (twitter: @avaskoog)
Friday, December 9th, 2016 4:49 pm

After using Unity for most of our more recent entries, I’m considering trying something simpler out this time, and just a few days ago I found out about a JavaScript framework called p5.js, which is basically a JS port of the Java framework Processing, in case anybody’s familiar with that. It makes it simple enough to draw things and play sounds in the browser in no time.

In order to learn how to use it and to get some fundamental stuff going (animated sprites, for example), I wrote up a few JS “classes” today. I’m still not sure whether I’ll be using p5.js at all, but in case somebody else wants to use my boilerplate stuff, feel free! c:

A glorious demo (live [warning: thunder audio at the beginning]: http://formo.ninja/LD37/test/):

View post on imgur.com

Fundamental files:

Less interesting but perhaps handy…

You’ll need to tie it up yourself, but I’m sure you can figure it out. The sprite and animation classes want an object from loadImage() and the animation requires a delta time, which you can calculate easily by using millis(). Animation class in particular is a bit tricky perhaps, with a bunch of settings, so read the comments in the file.

 

[cache: storing page]