Skip to content

CaldwellYSR/SplatJS

 
 

Repository files navigation

Splat ECS

A 2d HTML5 Canvas game engine

Splat ECS is a 2d game engine made for creating multi-platform games entirely in JavaScript. Splat ECS is built around the Entity Component System pattern, which is flexible and promotes composition of behaviors.

Features

  • Rectangles!
  • Keyboard, mouse, touch, & gamepad input
  • Sounds and music (Web Audio API and HTML5 Audio)
  • Sprite animation
  • Asset loading, and built-in loading screen
  • Games work well on phones, tablets, and desktop browsers.
  • A* Pathfinding
  • Particles
  • SCREENSHAKE
  • Tiled map editor support
  • Easing

Supported (tested) Platforms

  • Chrome (desktop & mobile)
  • Firefox
  • Internet Explorer (desktop & mobile)
  • Safari (desktop & mobile)
  • Mac using Electron
  • Linux x64 using Electron
  • Chrome Web Store (currently broken see issue #69)
  • Android using Cordova

Splat now works in Cordova, and due to updates to recent phone browsers we have seen good framerates on Android in google Chome. We have not tested Cordova builds on iOS yet, please let us know what you find out.

Requirements

  • Browser (like Firefox or Chrome)
  • Text editor
  • Terminal
  • Node.js

Create a new Game

  1. Clone or download a zip of the starter project

Create a file named game.js and start your game with this code:

"use strict";
var Splat = require("splat");

var canvas = document.getElementById("canvas");

var manifest = {
	"images": {},
	"sounds": {},
	"fonts": {},
	"animations": {}
};

var game = new Splat.Game(canvas, manifest);

game.scenes.add("title", new Splat.Scene(canvas, function() {
	// Initiaization
},function(elapsedMillis) {
	// Simulation
}, function(context) {
	// Draw
}));

game.scenes.switchTo("loading"); // Start loading scene which will switch to 'title' scene when all the assets in manifest are loaded.

Install browserify

$ npm install --save-dev browserify

Then use browserify to bundle your game as a single JavaScript file for the browser.

$ browserify game.js -o index.js

Include canvas element with id "canvas" and bundled JavaScript file (Splat + Game) on your html page:

<canvas id="canvas" width="1136" height="640"></canvas>
<script type="text/javascript" src="index.js"></script>

Games using Splat (ECS)

See more Splat games at http://splatjs.com/

Send a pull request to add your game to the list!

Contributing

If you are interested in participating in this project, please read CODE_OF_CONDUCT.md for details on our code of conduct.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.TXT file for details

About

A 2d HTML5 Canvas game engine

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.9%
  • CSS 0.1%