function update_animation(self)
    local vel = go.get(go.get_id(), "velocity")
    local anim = "idle"

    if math.abs(vel.x) > 10 then
        anim = "run"
        -- Flip sprite based on direction
        local flip = vel.x > 0 and
            1 or -1
        go.set(go.get_id(), "scale.x", flip)
    elseif not self.grounded then
        anim = vel.y > 0 and "jump" or "fall"
    end

    if anim ~= self.current_anim then
        self.current_anim = anim
        sprite.play_flipbook(
            go.get_id(), anim)
    end
end