Building a 2D Game Engine from scratch in pure ES6 Vanilla JS. Here is how I handle SpriteSheets & AnimatedSprites!
Hi everyone!
I've been working on **BeeEngine 2D**, a lightweight HTML5 game engine built with **pure Vanilla JS (ES6)** and direct Canvas API—no external libraries, no build tools, and zero heavy frameworks.
A lot of modern tools hide sheet slicing behind JSON files, but I wanted a bare-metal, highly efficient approach that gives 100/100 on Lighthouse Performance and instant loading times.
I separated the asset slicing logic from the animation timing logic into two distinct classes:
1. `BeeSpriteSheet`: Handles frame dimensions, columns, rows, and coordinate calculations. 2. `BeeAnimatedSprite`: Handles frame timing, state, loops, and `flipX` transformations.
Here is my `BeeAnimatedSprite` class implementation: