I want to know if there is a way of doing this simple enough for tutorials, but still very accurate.
An easy way I found is to have 2 modes. One is for moving on the ground, by looking up the ground height at the x pixel of the tile and the tile above it, and snapping it to the whatever ground is heighest. The other mode is for objects not on the ground, at it works the same except it is checked if the x coordinate has gone down through the ground. This has two problems. You can't have platforms directly above each other, or else the character will pop, and you can't move an object up at a slope that is less steep than the platform, or else it would incorrectly go through the platform.
I have another way that is more complicated. Instead of just checking if it went down through a point, it instead checks if the previous position was above the previous positions ground height. If it advanced a tile to the left or right of the previous frame, it splits it up into two parts. The first is move it to the left or right side of the tile, and then continue it to it's destination. If a destination is one block down and right of the previous block, and it was right above an up going slope, it will end up 2 tiles above the destination, requiring it to check 3 tiles instead of 2.
There must be an easier way than this, that I'm just not getting. Anyone have advice about this?
An easy way I found is to have 2 modes. One is for moving on the ground, by looking up the ground height at the x pixel of the tile and the tile above it, and snapping it to the whatever ground is heighest. The other mode is for objects not on the ground, at it works the same except it is checked if the x coordinate has gone down through the ground. This has two problems. You can't have platforms directly above each other, or else the character will pop, and you can't move an object up at a slope that is less steep than the platform, or else it would incorrectly go through the platform.
I have another way that is more complicated. Instead of just checking if it went down through a point, it instead checks if the previous position was above the previous positions ground height. If it advanced a tile to the left or right of the previous frame, it splits it up into two parts. The first is move it to the left or right side of the tile, and then continue it to it's destination. If a destination is one block down and right of the previous block, and it was right above an up going slope, it will end up 2 tiles above the destination, requiring it to check 3 tiles instead of 2.
There must be an easier way than this, that I'm just not getting. Anyone have advice about this?