A JavaScript implementation of Bloxorz game for a vector display-based home video game console Vectrex. View demo here: codepen.io.
-
Add JavaScript code containing class
Vectrex
in an HTML document:<script src="js/vectrex.js" type="text/javascript"></script>
-
Add HTML element for the game in
body
section:<div id="vectrex-container"></div>
-
Сreate an instance of class
Vectrex
after theDOMContentLoaded
event:document.addEventListener("DOMContentLoaded", () => { vectrex = new Vectrex("vectrex-container", 30); });
Class
Vectrex
constructor parameters:containerId
— ID of HTML element for the game;cellSizePx
— size of cell in pixels, default 10 pixels.
To add new levels modify this method of class Vectrex
:
class Vectrex {
...
setDefaultProperties() {
...
this.settings = {
...
levels: [
{
cells: [],
cellStartPosition: [],
cellFinishPosition: []
}