I'm rebuilding my game's collision system manually so that I can make it follow the NES more accurately. (Friendly reminder, I'm not actually building this for the NES, I'm just trying to emulate the NES.)
So far, it is going good. I have successfully made a falling object properly get blocked from falling through a floor.
I have never done something this close to a game's foundation before, so I'm going to describe it here in case someone knows a better way. The method I used was simple. Especially since I'm forcing the object to move in whole unit increments, It's really easy to predict movements and make sure that an object never moves too far. So I directly set the object's position to be that same position plus velocity. Then I have it check three points on the bottom to see if there is anything there that could be collided with. If so, the object is then moved to be directly on top of the ground. This is checked in the same frame so the object will never appear part-way through the ground. This would duplicate features I've seen in some games where if you jump up through a platform and are just barely near the top, you will instantly warp to the top.
I was about to basically duplicate the exact same method for collision on the sides, but then I realized wouldn't be able to properly duplicate some features I have seen.
Observe this sample from Castlevania.
castlevania3-0.png [ 5.88 KiB | Viewed 2351 times ]
Because of a valid reason, the player wound up partway in a wall. If the player moves away from the wall, they move freely and normally. If they move toward the wall, they can move no further. On the surface, that sounds easy enough. I only check the collision when they are moving, and in the direction they move. But the method I used to collide with the ground, if used here, would cause the player to instantly pop out the side of the block, instead of simply denying them from walking further into the wall.
If I have the side collision simply stop the player if it detects an object there, then it will be possibly to partially embed the player in any wall.
So the only way I can think to properly duplicate this design is to plug in special checks to see exactly how a player wound up in a wall, and then change the collision pattern according to that.
But that is really convoluted and is stacking the system to explicitly produce this result. I doubt that's how the collision in Castlevania was designed; I suspect that it was made in a straight-forward method and the fact that this happens is a byproduct of that method.
So... How is this game handling collision? How is this game actually keeping the player from walking into walls, such that if they happen to be in a wall they can walk through it?
So far, it is going good. I have successfully made a falling object properly get blocked from falling through a floor.
I have never done something this close to a game's foundation before, so I'm going to describe it here in case someone knows a better way. The method I used was simple. Especially since I'm forcing the object to move in whole unit increments, It's really easy to predict movements and make sure that an object never moves too far. So I directly set the object's position to be that same position plus velocity. Then I have it check three points on the bottom to see if there is anything there that could be collided with. If so, the object is then moved to be directly on top of the ground. This is checked in the same frame so the object will never appear part-way through the ground. This would duplicate features I've seen in some games where if you jump up through a platform and are just barely near the top, you will instantly warp to the top.
I was about to basically duplicate the exact same method for collision on the sides, but then I realized wouldn't be able to properly duplicate some features I have seen.
Observe this sample from Castlevania.
Attachment:
castlevania3-0.png [ 5.88 KiB | Viewed 2351 times ]
Because of a valid reason, the player wound up partway in a wall. If the player moves away from the wall, they move freely and normally. If they move toward the wall, they can move no further. On the surface, that sounds easy enough. I only check the collision when they are moving, and in the direction they move. But the method I used to collide with the ground, if used here, would cause the player to instantly pop out the side of the block, instead of simply denying them from walking further into the wall.
If I have the side collision simply stop the player if it detects an object there, then it will be possibly to partially embed the player in any wall.
So the only way I can think to properly duplicate this design is to plug in special checks to see exactly how a player wound up in a wall, and then change the collision pattern according to that.
But that is really convoluted and is stacking the system to explicitly produce this result. I doubt that's how the collision in Castlevania was designed; I suspect that it was made in a straight-forward method and the fact that this happens is a byproduct of that method.
So... How is this game handling collision? How is this game actually keeping the player from walking into walls, such that if they happen to be in a wall they can walk through it?