TL;DR version below.
Hi, this may be a bit of a specific and advanced topic for the Newbie Help Center, but I figure a lot of noobs get hit by this stumbling block so I'm posting here.
I'm trying to implement a basic tile-based background collision detection scheme for a platformer, and after the fifth or so try running into the same problems, I realized that my usual approach to doing things, i.e. beating my head against the wall until it works, is not going to cut it.
I have the basics down: I can sample a number of collision points around the character's hitbox and compare them against the map, if I detect a collision I can push him to the next tile boundary. My problems stem from a the following issue:
(Tile and hitbox proportions roughly to scale of what I'm aiming for.)
Let's assume I'm sampling the lower right corner point of the hitbox to check for collisions. The character is moving right and downwards. From this, I cannot actually tell if the character is intersecting with a wall or a floor.
If I check for horizontal collisions first, the character will get held up and moved to the left to the next tile boundary when walking on or landing on the floor. If I check for vertical collisions first, the character will properly register he's standing on the floor, but if I hit a vertical wall, the collision point will still trigger, and the character will be moved upwards to the next tile boundary instead.
I've tried various things to solve this issue, like using separate collision points for horizontal and vertical movement and spacing them apart in such a way they cannot be accidentally triggered, or trying to deduce if the character is hitting a wall or floor from the surrounding tiles, but all my attempts were either unsuccessful or had inherent weaknesses, such as being able to slip through one-tile-high gaps.
So, what I'm asking for is if anyone can give me any pointers on what I'm missing with my design, or if anyone could link me guides or references on how to implement tile collision detection with performance considerations such as on the NES, or perhaps examples of how actual games of the day did it. I am aware many games back in the day had many compromises and weaknesses in their designs, so I am rather looking for something to reference and study rather than to copy over one for one. I'm coming to my wit's end here, so any help would be much appreciated.
Cheers, -scrimpeh
TL;DR:
Background collision detection. Can't tell from a corner point if hitting wall or floor. Looking for pointers and references.
Hi, this may be a bit of a specific and advanced topic for the Newbie Help Center, but I figure a lot of noobs get hit by this stumbling block so I'm posting here.
I'm trying to implement a basic tile-based background collision detection scheme for a platformer, and after the fifth or so try running into the same problems, I realized that my usual approach to doing things, i.e. beating my head against the wall until it works, is not going to cut it.
I have the basics down: I can sample a number of collision points around the character's hitbox and compare them against the map, if I detect a collision I can push him to the next tile boundary. My problems stem from a the following issue:
(Tile and hitbox proportions roughly to scale of what I'm aiming for.)
Let's assume I'm sampling the lower right corner point of the hitbox to check for collisions. The character is moving right and downwards. From this, I cannot actually tell if the character is intersecting with a wall or a floor.
If I check for horizontal collisions first, the character will get held up and moved to the left to the next tile boundary when walking on or landing on the floor. If I check for vertical collisions first, the character will properly register he's standing on the floor, but if I hit a vertical wall, the collision point will still trigger, and the character will be moved upwards to the next tile boundary instead.
I've tried various things to solve this issue, like using separate collision points for horizontal and vertical movement and spacing them apart in such a way they cannot be accidentally triggered, or trying to deduce if the character is hitting a wall or floor from the surrounding tiles, but all my attempts were either unsuccessful or had inherent weaknesses, such as being able to slip through one-tile-high gaps.
So, what I'm asking for is if anyone can give me any pointers on what I'm missing with my design, or if anyone could link me guides or references on how to implement tile collision detection with performance considerations such as on the NES, or perhaps examples of how actual games of the day did it. I am aware many games back in the day had many compromises and weaknesses in their designs, so I am rather looking for something to reference and study rather than to copy over one for one. I'm coming to my wit's end here, so any help would be much appreciated.
Cheers, -scrimpeh
TL;DR:
Background collision detection. Can't tell from a corner point if hitting wall or floor. Looking for pointers and references.