DEV Community

Calin Baenen
Calin Baenen

Posted on

3 1

I now have an animated sprite!

So recently I've been working on refining the texture-handling system for my game, RuntDeale.
But, I finished polishing it (for now), so I ended up trying to do something a little more fancy for my next test-drive.

So, since I'm new to using Bevy and I don't know how much I truly understand, I decided to make a test "system" called speeen to test out how I could write a system for changing what the player looks like.
The function, in the words of Ceave Gaming, was "surprisingly simple", to make. Only five lines are used in the body.

/// Makes the player SPEEEEEEEEEEN.
pub fn speeen(
    mut spin_delay:ResMut<Timer>,
    mut player:Query<&mut TextureAtlasSprite, With<Player>>,
    time:Res<Time>
) {
    spin_delay.tick(time.delta());
    if spin_delay.just_finished() {
        for mut sprite in player.iter_mut() {
            sprite.index = (sprite.index+1) % 4;
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Anyways,
if you want to check out the test or leave feedback on my game, I'd greatly appreciate it.

Thanks for reading!
Cheers!

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay