Thread 11864802 - /vr/ [Archived: 230 hours ago]

Anonymous
7/13/2025, 3:43:35 AM No.11864802
images(1)
images(1)
md5: 8c6646adb25c1498e224c5abdbd385f4🔍
How did nes and old PC games handle collisions and keeping objects outside of each other's hit box?
Nowadays they just use boilerplate physics engines
Replies: >>11864804 >>11864825 >>11864954 >>11865020 >>11865186 >>11865301 >>11865467 >>11866323 >>11866915
Anonymous
7/13/2025, 3:44:38 AM No.11864804
>>11864802 (OP)
They programmed them idk
Replies: >>11865451
Anonymous
7/13/2025, 3:48:55 AM No.11864814
Each object had at least two pixels on each of its four sides. So for example, if you're moving left, you check if the left-bottom and left-top pixels are going to overlap some bounding box. If so, figure out how far into the box you are overlapping, and cut your velocity vector down to size so that the object sits flush against the bounding box.
Replies: >>11864829
Anonymous
7/13/2025, 3:54:11 AM No.11864825
>>11864802 (OP)
if (abs(obj1.x - obj2.x) < [some number] && abs(obj1.y - obj2.y) < [some other number]) {
collision = true;
}

Just do that in assembly
Replies: >>11864829 >>11864881
Anonymous
7/13/2025, 4:00:19 AM No.11864829
>>11864814
This is closer to my approach in unity while automatically refusing to use rigid bodies
>>11864825
This is also quite elegant , I like it a lot
Replies: >>11864834 >>11866862
Anonymous
7/13/2025, 4:01:46 AM No.11864834
>>11864829
>automatically
Autisticaly
Replies: >>11864864
Anonymous
7/13/2025, 4:14:22 AM No.11864864
>>11864834
Nothing autistic about it, the default Box2D physics in Unity is dogshit for making most 2D games, and you're expected to roll your own physics if you want more precision. Though these days they also have a new feature called Rigidbody2D.Slide that does all that for you.
Anonymous
7/13/2025, 4:25:52 AM No.11864881
Intersect
Intersect
md5: 1893ff5a06be1756aa8f1184569f9662🔍
>>11864825
There's a faster way to check rectangle overlaps given the upper right and lower left corner of each rectangle. This should be a specific result of https://en.m.wikipedia.org/wiki/Hyperplane_separation_theorem
Basically OP you gotta know your euclidean geometry
Replies: >>11864936
Anonymous
7/13/2025, 4:30:45 AM No.11864885
Fuck off, frog posting retard.
Replies: >>11864936
Anonymous
7/13/2025, 4:54:50 AM No.11864936
>>11864881
Cool, something to chew on. I'll try to work through some examples on paper tomorrow
>>11864885
*Shrugs"
Replies: >>11864967
Anonymous
7/13/2025, 5:02:27 AM No.11864954
1750063306063006
1750063306063006
md5: e449440aa06158bc7dbdfc831e00c20c🔍
>>11864802 (OP)
standard aabb collision function, but if you have a lot of objects on screen at once it can get particularly cpu intensive
in my homebrew game i just check at 30fps, even frames check collisions between player hurtbox and enemy hitboxes, odd frames check collisions between player hitbox and enemy hurtboxes
but checking collisions between every single object on screen is O(n^2) so a lot of old games with busy scenes do what doom does, really great video on it:
https://www.youtube.com/watch?v=-IYz6-KnvWU&t

@11864885
mental illness
https://desuarchive.org/_/search/text/Fuck%20off%2C%20frog%20posting%20retard/
Anonymous
7/13/2025, 5:07:17 AM No.11864967
>>11864936
This seems like a good explanation of it, alongside how to implement. They also go into more detail of what happens with rotatated rectangles:
https://code.tutsplus.com/collision-detection-using-the-separating-axis-theorem--gamedev-169t

The basic idea is that the only way for two (non rotated) rectangles in the plane to intersect is if their projections to the x axis overlaps and their projections to y axis overlaps.
Anonymous
7/13/2025, 5:40:46 AM No.11865020
>>11864802 (OP)
are you dumb? they did it the same way a physics engine does it. This is very basic game programming
Replies: >>11865023
Anonymous
7/13/2025, 5:44:15 AM No.11865023
>>11865020
Post game
Replies: >>11865172
Anonymous
7/13/2025, 7:53:39 AM No.11865172
>>11865023
go back to middle school and learn about vectors
Replies: >>11871105
Anonymous
7/13/2025, 8:01:28 AM No.11865186
>>11864802 (OP)
The coordinates of your character are stored as a sub-pixel value, and calculated this way.

Only when the graphic routines come to parse the coordinates and draw them to screen do they get turned into integers so that they can be assign an actual pixel value on screen.
Anonymous
7/13/2025, 9:01:14 AM No.11865301
>>11864802 (OP)
>store object coordinates
>add a routine that says
>>check an area X pixels wide and Y pixels tall around object"
>>if another object is in within said area go to collision routine
>>if not bail out
>repeat the process every frame
Anonymous
7/13/2025, 9:07:57 AM No.11865309
In what way? If you look at 2D games enemies have a hit box that can hurt the player, but both the enemy and player can frequently pass through one another. They often don't have hard collision with one another unlike the player and the level itself. Sometimes they'd not only have a hit box, but something the player collides into and cannot pass through with certain enemies or bosses so you can't just damage boost through something. There's a lot of complexity with the design of the player and enemies in 2D games that probably isn't mentioned much. It'd be interesting to see how it evolved in games.
Anonymous
7/13/2025, 10:03:50 AM No.11865375
at least on the atari you could do a sort of hardware level check for overlapped pixels, but generally 2d games have always just used aabb which is practically free anyways
Anonymous
7/13/2025, 11:05:29 AM No.11865448
spawn-ntsc
spawn-ntsc
md5: a76627586d5b1f499a733e1e0020ace2🔍
The MSX, Sg-1000 and all its offshoots up to the game gear had pixel perfect collision in the TMS9918 hardware but it was a memory hog so most games just used hitboxes. One of the games notable for using the hardware collision was the shitty Alf game. Interestingly it was found that the Mega Drive for some reason treats the SMS left border as a sprite, which can cause glitches in backwards compatibility mode.
Anonymous
7/13/2025, 11:07:22 AM No.11865451
>>11864804
This.
I have never had a Ouija board in my house, and I NEVER WILL. There are just some things you should never mess with.
Anonymous
7/13/2025, 11:16:43 AM No.11865467
>>11864802 (OP)
Doom and Mario 64's complete source code is out there, fully documented, and there are multiple youtube videos that explain exactly how collision works explaining all the code.

I think the GTA3 era games have pretty well documented collision too if you want something a little bit later and more complicated.
Anonymous
7/13/2025, 8:37:59 PM No.11866323
>>11864802 (OP)
The way they were programmed to do it. Because everyone wasn't just using a handful of "boilerplate physics engines" there were many different ways. I'm sure some retarded people even used some of the retarded """solutions""" provided ITT. There was no shortage of low skill homebrewers on the PC.
Replies: >>11866659
Anonymous
7/13/2025, 11:08:35 PM No.11866659
>>11866323
>I'm sure some retarded people even used some of the retarded """solutions""" provided ITT
The actual method developers used (aabb) has already been posted several times itt
Replies: >>11866868 >>11867038
Anonymous
7/14/2025, 1:35:08 AM No.11866862
>>11864829
>elegant
>just hardcode a bunch of ifs and loop for every existing object bro
Lol, lmao even.
Replies: >>11867283
Anonymous
7/14/2025, 1:37:53 AM No.11866868
>>11866659
>The actual method developers used (aabb)
This is some peak Dunning-Kruger. There were literally dozens of different methods devs used back in the day.
Replies: >>11867219
Anonymous
7/14/2025, 2:02:58 AM No.11866915
>>11864802 (OP)
>How did nes and old PC games handle collisions and keeping objects outside of each other's hit box?
A loop and xy or xyz cordinates it depends what era you mean, More modern games are main basic betor math and matrix multiplication

Heres a listing of old basic gaes for you to glance at.
https://ia801302.us.archive.org/21/items/sixty-programs-for-the-sinclair-zx-spectrum/sixty-programs-for-the-sinclair-zx-spectrum.pdf

Try porting one to python and then C if you want to learn. This is what 9/10/11/12/13/14 year old kids were doing in 1982 on commodores, ataris, spectrums, TRS80s etc typing in all that stuff and debugging it to make a game run. A lot fo the wqent on to write the games you have known and loved
Anonymous
7/14/2025, 3:24:39 AM No.11867038
>>11866659
>tards have posted several times itt
Indeed
Replies: >>11867285
Anonymous
7/14/2025, 5:02:53 AM No.11867219
screenshot
screenshot
md5: ff46dd8f1ef43ccd45c16ca6ba3bcce6🔍
>>11866868
Fair, I should've said "a" instead of "the". My point is though it's a common and easy way to check rectangle collision that was used at the time. SMB uses it to see if you hit an enemy/hammer/etc (with some extra checks for vertical wrapping): https://gist.github.com/1wErt3r/4048722
Anonymous
7/14/2025, 5:38:26 AM No.11867283
screenshot
screenshot
md5: 7cdc9f8c0617b015820407a5b45181d8🔍
>>11866862
Obviously there's some steps involved in deciding /which/ objects to check collisions for, but in the original Zelda this is in fact how they do it: https://github.com/aldonunez/zelda1-disassembly/blob/master/src/Z_01.asm
Anonymous
7/14/2025, 5:39:08 AM No.11867285
>>11867038
Post cock
Replies: >>11871356
Anonymous
7/15/2025, 12:56:48 AM No.11868812
If Mario = hit
Men - 1
ez
Anonymous
7/15/2025, 1:21:43 AM No.11868848
For Street Fighter 2 you had three rectangles that determined where your character could be hit (for head, torso and legs), one rectangle that determined where you are attacking (if it overlaps the opponent's previously mentioned rectangles, that counts as a hit) and one rectangle that determines the "solid" part of the character that makes them push against each other. These would all change shape and position depending on your current action.
Anonymous
7/15/2025, 7:50:32 PM No.11871105
>>11865172
>no game
Anonymous
7/15/2025, 9:33:29 PM No.11871356
i say boy youre fucking retarded
i say boy youre fucking retarded
md5: 66790a0336f8d08b9f340d7026a32ddb🔍
>>11867285
Anonymous
7/15/2025, 9:47:01 PM No.11871383
Pressure_Cooker_-_Sprites_Big
Pressure_Cooker_-_Sprites_Big
md5: 95b30c62490d1d2271e1b036fc82112c🔍
the Atari 2600 does pixel perfect hardware collision between all pairs of objects, including the playfield. with 5 objects plus playfield that's 15 pairs, and sure enough the CX registers have a total of 15 bits. it's one of the few nice things with it
most of the time games just use bounding boxes anyway, as other anons have said
Anonymous
7/15/2025, 9:49:15 PM No.11871392
Pretty much every system with hardware sprites could trigger interrupts on collision.