Problem description:
Hey guys! I've made a few light jabs at resolving pixel movement layering but I'm not coming up with any good solutions here.
Say I have a tree, and I set the bounds to only prevent the player from walking on where the tree's trunk meets the ground. If I set it to be above mobs, since the mob's bounds are set to only make its depth dense, as in.. from the feet to it's knees are dense.. The top half of the mob can go under the tree when it approaches it from the south.
If I set the layer beneath, that is resolved but approaching from the north makes out like you're in the tree.
This holds true for smaller structures to a less severe degree. I love the depth it gives to be able to walk up to walls and seem aligned with them, but this inconsistency is so lame.
Does anyone have any useful suggestions for fixing this issue?
ID:1108370
![]() Jan 1 2013, 6:21 pm
|
|
I think the SIDE_MAP map_format was intended to help with this, but I think some people have run into issues using it. You could try it and see if it works for you (read the reference entry for map_format and linked Side-view maps article for how it works). You might have to use pixel_y to get the origin set right, I'm not sure if they consider bound_y for that.
Failing that, the conventional solution is to break the icon into two parts, one layered above the players (the tree top) and one layered below (the stump). So long as the player isn't tall enough to intersect both parts at once, it should work. |
DC: I've thought of the conventional method, and it just seems so damn messy lol. Splitting the icons up like that is just..
I investigated side map, and it seems like a step in the right direction. The notion that lower y coordinates are closer makes sense. One other issue it brings though that I remembered is how same layer handling works. If you're on the same layer, (it seems as if) the most recently moved atom has a higher layer. If a mob approaches me from the north and enters into my tile, his feet are on my face (I laughed as I typed that for some reason), which is weird. I thought of some soft code for tackling this. What if I were to create layer modifiers which were used as guidelines to setting the layers when updated in the below system. Basically, your layer is relative to your y coordinate. Lower is higher so to speak. Your layer might for instance make use of a range, so it's like.. layer = layermod / y This way, the different types are still relatively higher than other types, but I haven't thought on the math heavily. layermod would have to always be at least as high as maxy though or it could possibly drop below 1. *strokes beard* Hm... |
That's the usual method for soft-coding what SIDE_MAP should do. I haven't worked with SIDE_MAP, so I don't know why you would see that "feet-on-face" behavior.
For the equation, something like this should work: layer = MOB_LAYER + (world.maxy - src.y)/world.maxy |
Oops, I didn't mean SIDE_MAP causes that, I meant it's an issue with the layering in general.
That math seems to work out decently, except for if src.y == world.maxy, then it's dividing by 0 lol. result <= 1 is always the case here, before the object's layer is added, so if they were at y == 1, and the MOB_LAYER == 4, thats 4 + .9~ == 4.9~, whereas if OBJ_LAYER == 3, on the same tile they're at 3.9~ so the mob is higher. The range isn't enough to get the effect, because moving y up or down by 1 isn't enough to cover that huge gap. I'm thinking the result has to be greater than 1 before the layer addition for this to work. If layers aren't rounded thats a great thing for this kind of system. If the result was that moving 1 tile made it modify by at least 2, it might work. MOB_LAYER = 4 OBJ_LAYER = 3 mob.y = 2 obj.y = 1 obj's layer would be 1 higher than mob's... I think this is right unless I made a mistake or forgot something. |
When src.y == world.maxy, you're dividing 0 by world.maxy, which is legit.
You'll have to use MOB_LAYER for both objs and mobs, of course. |
Er, I meant what would making the objs and mobs equal in layer accomplish, my bad.
|
For DC's equation, you'll have to use the same base layer (MOB_LAYER in his example) so that your mobs and objs interact by the same rules.
|
If I do that though, stepping on the same tile as an obj will put you on the same layer as them. Why not just slightly change a variable for each type and plug that in?
|
Basically, what you're asking for is a property of objects that say whether or not they're standing up. Players, trees, pillars, etc. are standing up, while the floor is not.
When a player is below a pillar, he should be layered above it. When the player is above the pillar, he should be layered behind it. Clearly, we can say that the player's position along the y-axis is related to his (and the pillar's) layer.
There's more to this, and I've done it a few times due to my dislike of the SIDE_MAP implementation, but I don't feel like contributing that, so I'll let you or someone else figure it out again.