Тёмный
No video :(

Pixel Perfect Collision Detection in C 

Nick Walton
Подписаться 6 тыс.
Просмотров 4,3 тыс.
50% 1

Опубликовано:

 

25 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 26   
@stackercoding2054
@stackercoding2054 7 месяцев назад
I spent the whole afternoon yesterday trying to figure out how to do sprite collisions like this, never thought of using a mask in this way, thanks for sharing the knowledge!
@UltimaN3rd
@UltimaN3rd 7 месяцев назад
Glad I could help mate :)
@shankar4510
@shankar4510 Год назад
I love How conside and short your codes are. Handmade hero also does a great job and he goes into every detail on windows programming but its little overwelming and in your case its easier and encouraging so thanks
@ytivarg5371
@ytivarg5371 Год назад
So detailed and imformative. Explained better than any tutorial ive read. Subscribed
@UltimaN3rd
@UltimaN3rd Год назад
Cheers mate, I try to strike that balance 😊
@dunkman393
@dunkman393 Год назад
Dude i remember watching your stream >>years
@UltimaN3rd
@UltimaN3rd Год назад
Thanks mate 😁 I'm glad I was able to bring your done joy; I had plenty of good times back then 😊 I put up a channel with as many of my old streams as I could for people from back then who want to revisit it. It's not monetized or anything 😉 www.youtube.com/@UltimaN3rdsStreamArchive/videos
@aidanswank5667
@aidanswank5667 Год назад
looking forward to collision response video!
@UltimaN3rd
@UltimaN3rd Год назад
It's a long time coming, but it will come :) I went through several iterations of code before arriving at the current one, and I've been developing my game further so as to put that collision code through more testing before putting it out there. The collision response video will be within my next few videos now 👍
@pixelgamesSARLS
@pixelgamesSARLS 4 месяца назад
Great video. I've been trying to adapt this to get it to work with raylib, but have been unsuccessful so far. CollisionMaskFromSprite -> incompatible pointer type error. Which makes sense, as the raylib Texture2D type is different from the mask type. Still have to figure it out... :)
@UltimaN3rd
@UltimaN3rd 4 месяца назад
Good luck mate 😊
@starc0w
@starc0w Год назад
Very cool! Thank you! 👍
@brecoldyls
@brecoldyls Год назад
Nice concise tutorial
@UltimaN3rd
@UltimaN3rd Год назад
Cheers mate, that's my goal 😊
@brecoldyls
@brecoldyls Год назад
@@UltimaN3rd I am curious though, in code for your actual projects do you store the mask's boolean values individually? For the sake of the tutorial it makes the concept much clearer, but in practice spending 8 bytes per bool when each one really only needs 1 byte.
@juanmacias5922
@juanmacias5922 Год назад
Dang, this is awesome!
@UltimaN3rd
@UltimaN3rd Год назад
Cheers mate! 😁
@_ab_6490
@_ab_6490 Год назад
I hope u explain to us how to read a truetype font file and load it as you did with bmp and wav sound new Subscriber
@UltimaN3rd
@UltimaN3rd Год назад
Truetype fonts are quite a bit more complex so initially I'll be showing how to use simple bitmap fonts, but I'm sure I'll get to Truetype as well. Cheers.
@UltimaN3rd
@UltimaN3rd Год назад
If more people request it I'll make it a priority though
@billkillernic
@billkillernic Год назад
Isnt that demanding too many resources? I mean first calculating if two shapes overlap and then calculate which of the color pixels of each shape are beyond that point etc imagine having 40 such shapes colliding with each other and needing to have all that calculated in a single frame per frame
@UltimaN3rd
@UltimaN3rd Год назад
Generally in a game you won't actually have that many objects overlapping, so the key to optimization is to use faster techniques to only check objects pixel-by-pixel when you know they're overlapping. Let's say you have 40 objects on-screen, probably most of them are only in the vicinity of 5 others, and ultimately only about 10 of them have any actual overlap with 1-3 other objects. Therefore you only need to do per-pixel checking for a few small overlapping areas a few of your objects. In low-resolution games such as many indie games, you could easily perform these types of collision checks for everything you need in each update cycle in a few hundred microseconds.
@Mr4NiceOne
@Mr4NiceOne Год назад
lol if you wrote done something like 40k or 400k, then sure, but 40? That's something probably my calculator's cpu could churn out couple of times a second
@Pokabbie
@Pokabbie Год назад
Worst case scenario, if it really was for some reason causing performance issue, you could always fallback on ol' reliable and generate a quad tree to speed up the pixel to pixel checks
@mss664
@mss664 Год назад
Also using a bool array is just wasteful, you can speed this up by packing data into bit masks. Once you have that you can use simd, if the compiler couldn't figure out how to vectorize your algorithm automatically. Depending on the available instruction set, you will be able to check 128, 256 or 512 pixels in a single (or few) CPU cycle(s).
@flavorlessquark8614
@flavorlessquark8614 Год назад
there's also very few cases where you would need exact pixel collision. Usually hotboxes are enough.
Далее
Draw Text in C with Bitmap Fonts
3:56
Просмотров 1,4 тыс.
拉了好大一坨#斗罗大陆#唐三小舞#小丑
00:11
HOW DID SHE DECIDE TO DO THIS?!
00:27
Просмотров 7 млн
Музыкальные пародии
00:28
Просмотров 19 тыс.
Switching to C - One Year Later
4:43
Просмотров 58 тыс.
How to Use Pygame Masks for Pixel Perfect Collision
10:28
Collision Detection (An Overview) (UPDATED!)
7:27
Просмотров 36 тыс.
10 FORBIDDEN Sorting Algorithms
9:41
Просмотров 845 тыс.
Pixel Art Animation. Reinvented - Astortion Devlog
4:41
Masks (and Pixel-Perfect Collisions) - Pygame Tutorial
17:35
how can memory safe code STOP HACKERS?
7:43
Просмотров 115 тыс.