Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Sprite Hit v Sprite Collision

Author
Message
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 16th Mar 2011 02:10
So, im pretty sure i read somewhere that sprite collision is a bounding box collision test whereas sprite hit is a much more accurate pixel collision checker. This would make sprite hit superior yet more labour intensive for the computer so a quick collision check to see if the bounding boxes collide first and only then do you go into a hit check to check more accurately. This all sounds fine to me but 2 things bother me.

1) They both do the same thing (i did a quick test and checked, plus a book that i have mentions that they are the same in a later chapter), i have obviously dreamed this solution up from somewhere and was wrong about collision being about bounding boxes and hit being about non-transparent pixels but it does beg the question why on earth have 2 commands that do the same thing. Why type collision when hit will do.

2) from everything i read about 2d collision on the forums so far it looks like a rediculously painful process to get decent collision, for such a basic program aimed at beginners i perhaps expected more (or less depending on how you want to look at it.)

Is it really so hard to get a nice little game going whilest at the same time playing decent enough to be just a little more than fun? The whole sprite collision thing seems to be getting a fair amount of people stuck and the solutions are difficult to understand. Maybe i am a little behind and the solutions arent making sense because its not my time to understand them yet but didnt anyone at TGC think of implementing the hit/collision to do what i just mentioned above. It would make things easier for people who have never coded before like myself and dont have a vast library of solutions to all manner of problems.
Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 16th Mar 2011 10:56
A single DBP detup doesn't do pixel perfect collision, as sad and stupid as it is, this is the truth.

You need to write a function for that yourself, or buy the costly Extends plugin.
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 16th Mar 2011 12:45
I think i have the extends plugin when i bought the DB game studio. How would i go about writing a function for it. Are there any decent tutorials anywhere? Perhaps a vid tutorial? I learn a lot better from videos rather than books for some reason.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 16th Mar 2011 22:23
Quote: "I think i have the extends plugin "

Great because I have a small sprites demo that uses extend commands. I'll attach the project folder. I hope it's what you're after.

A clever person solves a problem, a wise person avoids it - Albert Einstein

Attachments

Login to view attachments
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 16th Mar 2011 23:21
Hodgey thats amazing. Its absolutely spot on. Exactly what im looking for.

I am having trouble with the help files at the mo so i cant look at any of the extends stuff in depth just yet but im working on it .
I played around with the line:
collision = spr get collision(red.num, green.num, 1)
And changed it to 0. This just returns whether it has hit or not which is nice. But set to one (like it is above) is marvellous. Does it return the number of pixels that are overlapping. If this is the case i could think of a good use for it. For example a character running through fire or lava perhaps, the more pixels covered the more faster the damage on the burns variable

This is just great and eactly what the difference between sprite hit and collision should be, instead i will now just use one of these in conjunction with the extends command (so i am not constantly checking for pixel perfect collision, only when bounding boxes overlap) unless it isnt particularly computer intensive to do this throughout the game.

Once again Hodgey, thanks a lot. I love it!
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 17th Mar 2011 06:28
Quote: "Its absolutely spot on. Exactly what im looking for."

Glad to hear it.

I will warn you now though, unfortunately, the extends sprite collision commands seem to only work with bitmaps. I have just spent a good hour testing the commands on pngs with transparency and no luck. But this shouldn't be too big of a set back as most art programs will allow you save your images as a bitmap.

A clever person solves a problem, a wise person avoids it - Albert Einstein
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 17th Mar 2011 13:01
Mmmm thats unusual that it doesnt support anything but bmps. I much prefer using pngs and sorting all the transparency before popping into DB pro but at least this works and ill happily do whatever it is i wanted to do with it

I wonder if there is a way to make it support pngs? Maybe someone who knows about dlls could perhaps manipulate it to work, maybe somebody already has? I have only been coding for just over a month so i wouldnt have a clue where to start but it would be nice to see.

Thanks again!
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 17th Mar 2011 13:29
It is a real shame, I even tried importing a png into extends collision demo (which was able to accomplish pixel perfect collision using DBPro's sprite collision commands ). It detected collision but the problem was that it was detecting the invisible pixels which kind of defeats the purpose of pixel perfect collision. I'll keep experimenting and I'll let you know if I find away.

A clever person solves a problem, a wise person avoids it - Albert Einstein
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 17th Mar 2011 13:58
Thanks man, i would appreciate it if you found the perfect solution, that would be great. I wish i could help but im a month in and still getting confused with the basics just yet so i wouldnt know where to start
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 19th Mar 2011 20:30
Just want to throw something out there. eXtends is not compatable with windows vista or 7.

I am on windows vista and it works fine. Whats happening here? Why is it working? Have they fixed eXtends to work with vista now?
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 19th Mar 2011 23:40
Quote: "eXtends is not compatable with windows vista or 7. "

Quote: "I am on windows vista and it works fine."

Quote: " Why is it working?"

Sorry, you lost me.

I'm running windows 7 and the collision commands work here. However, I have noticed that extend's sprite drawing commands are buggy so I just use DBPro's sprite drawing commands with extend collision commands as seen in my demo.

A clever person solves a problem, a wise person avoids it - Albert Einstein
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 19th Mar 2011 23:51
Yeah i know but i read in 2 places that its not compatable with 7 or vista, also look on tgc website under eXtends, it also says it there in bold writing. Yet it works fine for me and obviously fine for you. How odd. Maybe not all the features are compatable but thanksfully the sprite collision is.

Login to post a reply

Server time is: 2024-11-22 23:16:28
Your offset time is: 2024-11-22 23:16:28