Immobile objects (like grass/wall/tree) need only set their depth once to their y-coordinate. Vertically moving things need to do this every frame to correctly go in front/behind of other things.