Polychaete is primarily written in "vanilla" ES6 JavaScript. Webpack and Babel are used to transpile from ES6 for greater browser compatibility. External dependencies include EaselJS for sprite animation and movement, Tone.js for synth-based sounds, and js-cookie for easier cookie handling.
See the Development README to learn more about the development process.
All in-game characters/objects extend the GameObject
base class. This provides base size, movement/positioning, and sprite functionality. Objects that move automatically based on time extend MovingObject
, a subclass of GameObject
. This provides direction and velocity attributes and a generic updatePosition
method. Functionality unique to specific subclasses includes the following:
Diver
: Laser firing ability.Bubble
: Supports three different bubble sizes and randomly changing x direction. Uses theupdatePosition
method inherited fromMovingObject
.LaserBeam
: Laser beams move vertically in a straight line, they use theupdatePosition
method inherited fromMovingObject
.SeaSponge
: Handling of multiple laser beam hits.Shrimp
: Provides adropSeaSponge
method which can be called to drop a sea sponge at the shrimp's current position. (Shrimps move vertically in a straight line, so they use theupdatePosition
method inherited fromMovingObject
.)Crab
: Provides a customupdatePosition
method with helper methods to change direction and velocity semi-randomly at 'decision points'.Segment
: Polychaete segment movement and connection to adjacent segments (linked-list style).Head
: Class/static method to create a new Head based on an existing Segment.Score
: Class/static method to display the associated score over an enemy that has been destroyed.
- The
Game
class manages the overall game state. Due to the complexity of the associated code, position updates and collision detection were moved into separate classes:- The
PositionHandler
class updates the positions of allMovingObject
s. - The
CollisionHandler
class handles collision detection for in game objects.
- The
- The
Board
class maintains position and rendering of the various game objects on the Canvas, as well as addition and removal of those objects. - The
KeyHandler
provides a keyboard-based user interface to move the diver and fire laser beams. - The
UIHandler
manages state and interactivity of dynamic HTML elements other than the canvas itself, such as popups and buttons. - The
SoundHandler
implements sounds for various in-game actions.
An up to date version of npm.
git clone https://github.com/jwoldan/polychaete.git
cd polychaete
npm install
npm run webpack-once
npm install -g http-server
(This globally installs a simple web server to serve the page locally)http-server
- Visit
http://localhost:8080/