I have a problem related to z-ordering of various game elements that I think is insurmountable but thought I’d post it in case someone has a great suggestion!
I have a 2d side-scrolling game.
There is a ‘subterranean’ layer at z-order 10 - this contains a large texture of ‘rocks’
There is a ‘surface’ layer on top of that at z-order 20 - this contains the surface on which the hero is walking (e.g. a path)
I have a ‘particle’ layer with various particle effects emanating from the player.
The particle layer needs to be in front of the surface, but behind the sub-terrain, so that the particle effects are in front of the surface but behind the sub-terrain.
I can’t see any way of achieving this as z-order 0 is behind both, 15 is on top of sub-terrain and behind surface, and 25 is in front of both.
Here’s a screenshot. The subterrain is the lava, the path and fence are the surface
There’s no particles in the right place in the screenshot - but imagine the pig has a large particle effect, I want it to appear in front of the fence (surface layer) but behind the lava) sub-terrain layer.
Obviously while the terrain i s flat like this it would be relatively simple to mask it or something - but the terrain is pretty varied (hills, holes, valleys etc.)
The only reason is that the top of the subterrain is very ‘flat’ - i.e. is comprises a series of straight lines filled with texture, so with it in front of everytihng there is no way to disguise that.
By putting the ground on top of it I can overlay them slightly, and so it doesn’t look quite as ‘manufactured’ (the bottom of the road, for example, is not flat, but slightly ‘lumpy’)
Moon, sky and stars and dunes are in fact separate and have awesome parallax action!!
ahhh I understand what you are going for now. OK two more suggestions then. One easy thing is you use the ordering I suggested but also just make the top of the subterrain layer a little jagged instead of straight. But what I really think you should do is modify the particle code so that particles never go lower than the y-value of Pooper’s feet when she is standing on the surface - so the particles would actually stop at the vertical midpoint of the road. When a particle’s y-value is lower than that - clamp it to that midpoint and set the delta-y value to 0, but let it keep moving horizontally. Like when a rocket goes up the engine smoke goes down until it hits the ground and then it spreads out (it doesnt just go down and disappear through the ground)
Unfortunately yes - see the 2nd picture I uploaded.
But great suggestion - I could look at the particle code and see if its easy enough to at least set a lower y limit - even if the particle Y stopped at that value, it would only overlap terrain in a valley so it might look awesome.
Thanks!
Thanks for your suggestions on this - I changed the particle code to stop movement in the Y direction below a height - and it looked great on flat terrain!
but too hard to do all the calculations needed to cope with hills and valleys
So instead I have moved by terrain (ground) behind the subterrain (lava) and added a ‘foregroundterrain’ in front of everything.
this new layer helps ‘soften’ the harsh surface of the subterrain, and allows the particles to be on front of the surface but behind the subterrain.