Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jansedivy/potion
HTML5 canvas game engine
https://github.com/jansedivy/potion
Last synced: 14 days ago
JSON representation
HTML5 canvas game engine
- Host: GitHub
- URL: https://github.com/jansedivy/potion
- Owner: jansedivy
- License: mit
- Created: 2014-02-03T18:28:08.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-04-16T16:49:51.000Z (over 8 years ago)
- Last Synced: 2024-10-05T00:08:42.369Z (about 1 month ago)
- Language: JavaScript
- Size: 2.24 MB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Potion
[![npm version](https://badge.fury.io/js/potion.svg)](http://badge.fury.io/js/potion)
Potion is a game library with simple and useful abstractions.
- Asset loader
- Input event handling
- Sound manager
- State manager
- Multi-layered canvas
- HiDPI monitor support
- Debugger for in game logging and switch toggling#### [Examples](http://potionjs.com)
## Documentation
- [API](/docs/api/)
## Installation
Potion is compatible with CommonJS modules. Can be used with browserify,
webpack and others. You can install it from npm.```sh
npm install potion
```There is also a built version you can download
- [potion.js](https://raw.githubusercontent.com/jansedivy/potion/master/build/potion.js)
- [potion.min.js](https://raw.githubusercontent.com/jansedivy/potion/master/build/potion.min.js)## Usage
```html
``````javascript
var Potion = require('potion');var app = Potion.init(document.querySelector('.container'), {
configure: function() {
app.resize(400, 400);
},init: function() {
this.x = 0;
this.y = 0;
this.dx = 0;
this.dy = 0;
},update: function(time) {
if (app.input.isKeyDown('w')) { this.dy -= 5000 * time; }
if (app.input.isKeyDown('d')) { this.dx += 5000 * time; }
if (app.input.isKeyDown('s')) { this.dy += 5000 * time; }
if (app.input.isKeyDown('a')) { this.dx -= 5000 * time; }this.dx = this.dx + (0 - this.dx) * 8 * time;
this.dy = this.dy + (0 - this.dy) * 8 * time;this.x += this.dx * time;
this.y += this.dy * time;
},render: function() {
app.video.ctx.fillRect(this.x, this.y, 10, 10);
}
});
```## See also
- [Potion Audio](https://github.com/jansedivy/potion-audio)
- [Potion Debugger](https://github.com/jansedivy/potion-debugger)
- [Potion Template](https://github.com/jansedivy/potion-template)## License
[MIT license](http://opensource.org/licenses/mit-license.php)