Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chipbell4/peach.js
A small rendering engine for pixely canvas games
https://github.com/chipbell4/peach.js
canvas game-engine pixel-art
Last synced: 9 days ago
JSON representation
A small rendering engine for pixely canvas games
- Host: GitHub
- URL: https://github.com/chipbell4/peach.js
- Owner: chipbell4
- Created: 2012-10-28T20:53:21.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T08:25:52.000Z (almost 2 years ago)
- Last Synced: 2024-10-30T16:09:27.804Z (17 days ago)
- Topics: canvas, game-engine, pixel-art
- Language: JavaScript
- Homepage:
- Size: 248 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
peach.js
========
![Build Status](https://travis-ci.org/chipbell4/peach.js.svg?branch=develop)## Usage
Create a renderer by instantiating a `Peach` instance:```javascript
var width = 320;
var height = 240;
var palette = [0xff0000, 0x00ff00, 0x0000ff];
var renderer = new Peach(width, height, palette);
```From there, you can manually set pixels and render them:
```javascript
var x = 20;
var y = 30;
var paletteIndex = 2; // use the index 2 palette color, blue in this case
renderer.setPixel(x, y, paletteIndex);
renderer.render();
```Or, you can create a sprite:
```javascript
var bitmap = [
[0, 1],
[1, 1]
];var paletteAssignment = {
0: 2, // bitmap value 0 is assigned to palette color 2 (blue)
1: 1 // bitmap value 1 is assigned to palette color 1 (green)
};
var sprite = new Peach.Sprite(bitmap, paletteAssignment);
sprite.x = 20;
sprite.y = 30;
renderer.sprites.push(sprite);
renderer.render();
```