DEV Community

Cover image for ๐ŸŽฎ Introducing Pixalo โ€” A Lightweight, Developer-Friendly 2D Game Engine for JavaScript
Salar Izadi
Salar Izadi

Posted on

๐ŸŽฎ Introducing Pixalo โ€” A Lightweight, Developer-Friendly 2D Game Engine for JavaScript

Building 2D games in JavaScript should be simple โ€” not a constant struggle with complex APIs and endless setup.
Thatโ€™s exactly why I built Pixalo.


๐Ÿ’ก Why I Created Pixalo

I wanted a way to make 2D game development as easy as writing HTML, CSS, or even jQuery โ€” where you can create, animate, and control elements effortlessly without writing dozens of lines of code for a single sprite.

While many JavaScript game engines exist, they often require heavy configurations or WebGL setup.
Pixalo skips the complexity while staying fast, lightweight, and flexible โ€” using optimized rendering techniques and even OffscreenCanvas Workers to maintain excellent FPS, even with many objects on screen.


๐Ÿš€ What Pixalo Can Do

Pixalo comes packed with everything you need to build smooth, feature-rich 2D games:

  • ๐Ÿƒ Advanced animation support with keyframes
  • ๐ŸŽจ Layered background management
  • ๐Ÿ“ Grid system with customizable properties
  • ๐Ÿ”„ Sprite sheet and asset management
  • ๐Ÿ’ฅ Collision detection
  • โš™๏ธ Physics support powered by the legendary Box2D
  • ๐ŸŽต Spatial audio controls
  • ๐Ÿ—บ๏ธ Tile map system for level design
  • ๐ŸŽ† Particle emitter system
  • ๐Ÿ“ธ Screenshot support
  • ๐Ÿ“น Camera system (zoom, rotation, cinematic presets)
  • ๐ŸŽš๏ธ Quality control & scaling options
  • ๐Ÿž Built-in debugging tools

Itโ€™s not just a game engine โ€” you can even use it as a Canvas Editor, drawing and animating anything you want right on the canvas.


๐Ÿงฉ Getting Started

You can use Pixalo either via ESM import or CDN โ€” no build tools required.

import Pixalo from 'https://cdn.jsdelivr.net/gh/pixalo/pixalo@master/dist/pixalo.esm.js';

const px = new Pixalo('#canvas', { 
    width: innerWidth,
    height: innerHeight
});
px.start();
Enter fullscreen mode Exit fullscreen mode

๐ŸŸฆ Drawing Shapes

Creating shapes in Pixalo is ridiculously simple.

Draw a rectangle:

px.append('myRectangle', {
    width: 100,
    height: 100,
    fill: 'blue',
    borderRadius: 6
});
Enter fullscreen mode Exit fullscreen mode

Draw a circle:

px.append('myCircle', {
    shape: 'circle',
    width: 100,
    height: 100,
    fill: 'red'
});
Enter fullscreen mode Exit fullscreen mode

Handle click events:

px.find('myRectangle').on('click', e => {
    px.append('text', {
         x: px.baseWidth / 2,
         y: px.baseHeight / 2,
         text: 'You clicked on the rectangle',
         font: '16px Arial'
    });
});
Enter fullscreen mode Exit fullscreen mode

๐Ÿ”บ Polygons Made Easy

Even complex shapes like polygons are straightforward to draw:

const size = 100;
px.append('polygon', {
    width: size,
    height: size,
    x: (px.baseWidth  - size) / 2,
    y: (px.baseHeight - size) / 2,
    fill: '#268984',
    shape: 'polygon',
    points: [
        {x: -size / 2, y: -size / 2},
        {x: size / 2, y: -size / 2},
        {x: size / 2, y: 0},
        {x: 0, y: size / 2},
        {x: -size / 2, y: 0}
    ]
});
Enter fullscreen mode Exit fullscreen mode

๐Ÿ•น๏ธ Example: Player Movement

Hereโ€™s a simple player movement example using keyboard controls:

import Pixalo from 'https://cdn.jsdelivr.net/gh/pixalo/pixalo@master/dist/pixalo.esm.js';

const game = new Pixalo('#canvas', {
    width : window.innerWidth,
    height: window.innerHeight
});

await game.loadAsset('image', 'player', 'https://raw.githubusercontent.com/pixalo/pixalo/refs/heads/main/examples/assets/character.png');

game.start();

const player = game.append('player', {
    width: 100,
    height: 100,
    x: 10,
    y: 10,
    image: 'player'
});

game.on('update', deltaTime => {
    const speed = 150;
    const step = speed * (deltaTime / 1000);
    let dx = 0, dy = 0;
    const leftKey = game.isKeyPressed('left', 'a');

    if (leftKey) dx -= step;
    if (game.isKeyPressed('right', 'd')) dx += step;
    if (game.isKeyPressed('up', 'w')) dy -= step;
    if (game.isKeyPressed('down', 's')) dy += step;

    player.style('flipX', leftKey).move(dx, dy);
});
Enter fullscreen mode Exit fullscreen mode

๐ŸŒ Try Pixalo Yourself

Pixalo is still evolving โ€” WebGL support is coming soon โ€” but itโ€™s already stable, fast, and fun to use.
Whether youโ€™re prototyping or building a full indie game, Pixalo aims to make your workflow smooth and intuitive.

๐Ÿ‘‰ Website: https://pixalo.xyz
๐Ÿ‘‰ GitHub: https://github.com/pixalo/pixalo


๐Ÿ’ฌ Final Thoughts

Pixalo was built with one simple goal:

To make 2D game development feel natural, expressive, and enjoyable โ€” not tedious.

If you love making games in JavaScript and want a fresh, developer-friendly engine, give Pixalo a try and share your feedback. Every contribution and idea helps shape its future.

Top comments (1)

Collapse
 
xdevman1 profile image
Milad

Can't wait to try this. Thank you!