Dbug sprite algorithm