int dir = 0;
if (x * 16 + 8 > mario.x + 16) dir = -1;
if (x * 16 + 8 < mario.x - 16) dir = 1;
SpriteTemplate st = level.getSpriteTemplate(x, y);
if (st != null)
{
if (st.lastVisibleTick != tick - 1)
{
if (st.sprite == null || !sprites.contains(st.sprite))
{
st.spawn(this, x, y, dir);
}
}
st.lastVisibleTick = tick;
}