1.8.5 • Published 6 months ago
@pixelation/engine v1.8.5
@pixelation/engine
A simple pixel art game engine.
Installation
npm install @pixelation/engineUsage
To start using the Pixelation Engine, import this library and call the run lifecycle function.
This function requires the following options:
screen: Anengine.graphics.Screenorengine.graphics.VirtualScreento draw to.setup: Anengine.lifecycle.Setupfunction which is called before running other code.update: Anengine.lifecycle.Updatefunction which is called before rendering each frame.render: Anengine.lifecycle.Renderfunction which is called to render each frame.
import * as engine from "@pixelation/engine";
// Create a screen to draw to.
const screen = new engine.graphics.Screen(100, 100);
const setup: engine.lifecycle.Setup = (surface, inputs, audio) => {
// Add the screen to the page.
document.body.appendChild(screen.canvas);
};
const update: engine.lifecycle.Update = (surface, inputs, audio, dt, t) => {
// Here you can handle things like user inputs or process game logic.
if (inputs.keyboard.pressed("w")) {
// ...
}
};
const render: engine.lifecycle.Render = (surface, inputs, dt, t) => {
// Here you can render to the current rendering target `surface`.
surface.fillRect(
0,
0,
surface.width,
surface.height,
engine.colors.fromHsl(0.65, 0.8, 0.75)
);
};
engine.lifecycle.run({
surface: screen,
setup,
update,
render,
});Examples
For reference examples, please see ./examples.
In addition, the code for the engine is fairly short, so it should be possible to read through to get a better understanding. Don't be intimidated, this stuff ended up being easier than it seems!
1.8.5
6 months ago
1.8.4
10 months ago
1.8.3
10 months ago
1.8.2
10 months ago
1.8.1
10 months ago
1.8.0
10 months ago
1.7.0
10 months ago
1.6.1
10 months ago
1.6.0
10 months ago
1.5.0
10 months ago
1.4.1
11 months ago
1.4.0
11 months ago
1.3.0
12 months ago
1.2.0
12 months ago
1.1.1
12 months ago
1.1.0
12 months ago
1.0.0
12 months ago