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.

DarkBASIC Professional Discussion / Disable transparent sprite collision?

Author
Message
Aralox
17
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 22nd Feb 2009 11:06
How do i disregard transparency when checking for collision with two sprites?
i did a search, and the one thread which had my question exactly dwindled to nothing.
http://forum.thegamecreators.com/?m=forum_view&t=133603&b=1
Hoping someone can help me with this,
Aralox

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Feb 2009 11:34
Did you try this?

sprite collision

I haven't tried it myself but at first sight it seems related to your problem.

[I found that link by doing a search for sprite collision.]
Aralox
17
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 23rd Feb 2009 08:18
hmm no, doesnt seem to work, i turned off offsetting on my sprites but still no. =(
do you think the advancedsprites plugin would help? i had a look, but i cant see any collision functions.

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 24th Feb 2009 00:17
Doesn't seem to work? Well what are you trying to do?

Here, I've written a little example using my library. I just kinda pasted all the code at the end.

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 24th Feb 2009 01:20
Oh, and I realize I didn't call my own InitSpriteCollision() function before using other commands from the library, as I said was necessary in the thread Green Gandalf gave the link to, but the initialization function is only necessary for "point on sprite" collisions and when a transparent color other than black is needed.
Aralox
17
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 24th Feb 2009 10:36
wow your example worked perfectly, even after i changed the box to a circle, and then replaced that with a png. thank you. however one thing i still need that the library doesnt support (i know youve mentioned this) is sprite offsetting. hmm how hard do you reckon it would be to impement this feature? ill give it a go

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 24th Feb 2009 21:47 Edited at: 24th Feb 2009 21:49
Hm, I'll take a look. I don't suspect it'll be impossibly challenging. In the mean time, you could always just subtract the offset coordinates from the actual, every time you move the sprite.

Something like this:
Aralox
17
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 24th Feb 2009 22:57
hey good idea ill try it

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 24th Feb 2009 23:11
Actually, you needn't try it. I just revised the library to support offsetting. Maybe I'll give scaling another whack too...

Here's the new example:



Here's the new library:



And the source file for the library is attached as well.

Attachments

Login to view attachments
Aralox
17
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 25th Feb 2009 00:38 Edited at: 25th Feb 2009 00:44
Thank you, kira vakaan, it works beautifully!
except for one thing, the sprite im checking collision for is constantly rotating.
hmm, ill try rotating it back to 0 degrees when checking collision, then rerotating it to its previous position. it should work, but will cause a drop in fps i think

EDIT: oh wait that wont do anything, itll still be checking the same sprite location. hmmmm

EDIT2: is there a way to check collision for the sprite, instead of the sprites image? wait that sounds silly even to me

Login to post a reply

Server time is: 2024-05-02 00:48:52
Your offset time is: 2024-05-02 00:48:52