A lightweight TypeScript game framework built on the HTML5 Canvas API, inspired by pygame. It provides familiar constructs like Surface, Vector2, Rect, Sprite, and Scene management for rapid 2D game development in the browser.
⚡ Write code that feels like pygame, but runs natively in the browser.
- Graphics
Surfacewrapper around<canvas>with blitting support- Easy image loading via
BlitJS.image.load() - Drawing utilities(
line,rect, etc.)
- Audio
BlitJS.audio.SoundandBlitJS.audio.Musicwrappers aroundHTMLAudioElement
- Display
BlitJS.display.setMode()→ create the game canvasdisplay.update()→ update the screen
- Core Math Utilities
Vector2,Vector3with common operations (dot, cross, normalize, etc.)Rectfor bounding boxes and collision checks- Handy functions like
clamp,lerp
- Masks
# Clone the repo
git clone https://github.com/devnmarki/blit-js.git
cd blit-js
# Install dependencies
npm installOr add it as a dependency to your project:
npm install blit-js
import { BlitJS } from "blit-js";
async function main() {
const screen = BlitJS.display.setMode([800, 600]);
const clock = new BlitJS.time.Clock();
const playerImg = await BlitJS.image.load("player.png");
function loop() {
screen.fill({ r: 255, g: 255, b: 255, a: 1 });
screen.blit(playerImg, [100, 100]);
clock.tick(60);
screen.update();
requestAnimationFrame(loop);
}
loop();
}
main();Contributions are welcome! Feel free to:
- Open issues for bugs & suggestions
- Submit PRs with improvements
- Help expand the examples and documentation
MIT License © 2025 Marko Smiljic
This project is independent and not affiliated with pygame. Pygame is a separate project under the LGPL license. This repo is just inspired by its design philosophy.