[ACCEPTED]-How did older games do collision detection with walls, floors and ceilings?-collision-detection

Accepted answer
Score: 18

For the types of NES-era games you're talking 22 about, everything was 2D. That alone simplifies 21 many things.

Some machines of that era (particularly 20 ones with hardware sprites, like the Commodore 19 64) had hardware collision detection. Most 18 games that weren't relying on hardware collision 17 detection would either use a bounding box 16 or a hit mask (1-bit bitmap of the sprite).

Either 15 way, collision detection was usually done 14 "a posteriori", except for special cases 13 like the edges of the world. Some games 12 actually did have bugs where moving too 11 fast when you hit something could cause 10 you to pass through it. (In fact, reviews 9 of early 80's games would often comment 8 on how precise the collision detection was.)

For 7 platformers, you'd typically check to see 6 if the character is "grounded" before applying 5 gravity.

The one-way platforms thing isn't 4 too hard to deal with after the fact since 3 you know the sprite's velocity vector, so 2 you can use that to determine whether or 1 not the collision should register.

Score: 14

There is article here that is an in-depth look at programming a Nintendo Entertainment System (NES) "platform game".

I may not 2 have been googling right because I haven't 1 stumbled upon this article before.

Score: 13

For games such as Super Mario World (SNES), the 10 game stored the levels in a memory format 9 that made it easy to take Mario's X/Y location, convert 8 it to a tile address, and then check the 7 tiles immediately around that address. Since 6 the levels were always a fixed width (though 5 the area you could view varied), it made 4 addressing easier to manage since it was 3 always a fixed offset from mario's position, e.g. Address 2 + 1 for the tile beside mario, Address + 0x300 1 for the tile below him, etc.

Score: 1

In older games collision detection was often 19 less than perfect, trading accuracy for 18 performance.

For example, in Super Mario 17 Bros. collision with enemies is only checked 16 every other frame. Collision with the end-of-level 15 flag pole is done only once every 27 frames. There 14 is also a limit on the maximum number of 13 objects checked for collisions, which famously 12 allows you to pass through some of Browser's 11 attacks at the end of the game without dying.

Another 10 example is the PC Engine port of Gradius. Rather 9 than using more expensive bounding box hit 8 detection, it uses a tile system. Each object 7 is reduced to a tile number, consisting 6 of the X and Y position rounded to a multiple 5 of 8 and concatenated into a single number. If 4 two objects occupy the same 8x8 tile they 3 are deemed to have collided. It's less accurate 2 but tends to favour the player, so presents 1 an acceptable and fun compromise.

More Related questions