
I guess we now have Sprite Animations
A while back I posted something about wgpu, and making a game engine. I've since worked on it a bit more, and now we somehow have Animated Sprites! 🎉 Yay! Here’s how it works: I loaded a spritesheet and slice it into individual sprites. These sprites are grouped into animations, which are then handed off to the SpriteAnimator. The SpriteAnimator tells the SpriteRenderer which sprite to display at any given time. The sprites aren’t independent images. Each one stores UV coordinates corresponding to its region on the spritesheet. The SpriteRenderer then simply renders a 2D quad using the sprite’s UV coordinates, effectively showing the correct pixels from the spritesheet. Meanwhile, the SpriteAnimator handles all the animation logic, controlling which sprite the renderer should display and when. It’s rather simple, really. Here it is in action: P.S: I also implemented text rendering as you can see in the FPS counter at the top left corner of the window in the example gif. Perhaps I will
Continue reading on Dev.to
Opens in a new tab

