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 / Question to Ian M/ Freddixx or anyone else that has written a 2d pixel perfect collision function

Author
Message
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 12th May 2004 21:09
I just wondered: how does your collision system actually work? Does it use the sprites co-ordinates or is there a way for you to get it working using the offset sprite command because at present i can't seem to get it to do it.

Any help would be greatly apreciated,

Michael


Visit the Code Monkey's website at http://www.codemonkeystudios.tk
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th May 2004 23:27
The code that I posted to CodeBase won't work if:

1 - you are not in a 32 bit mode
2 - you are scaling your sprite
3 - you are rotating your sprite

If the above points are not causing the problem that you have, then I don't know what the problem is. The code correctly takes into account the sprite offset position in the following two lines:

XPos2=sprite x(sprite2)-sprite offset x(sprite2)
YPos2=sprite y(sprite2)-sprite offset y(sprite2)

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 13th May 2004 01:03
Does it work for .png's that have had black(0,0,0) set as transparent because i have done what you have said and it doesnt work?


Visit the Code Monkey's website at http://www.codemonkeystudios.tk
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th May 2004 01:18
PNG files have their own transparency layer and they ignore the transparency colour that you set when you load them.

There is a little trick you can use to make DBPro use a transparency colour instead, but it's slipped my mind - it's something that Spooky worked out when U4 came out and changed the way that PNGs worked.

I suggest that you either use a bitmap for now, or use the PNG transparency layer instead. In the meantime, I'll try and remember the trick.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 13th May 2004 21:52 Edited at: 13th May 2004 21:52
I have tried everything you said. It now loads fine and makes the player fall onto the platform where he stops. Then the program exits for some unknown reason. I have tried this several times and it still does it. I have enclosed my source code at the bottom.

Cheers,

Michael


Visit the Code Monkey's website at http://www.codemonkeystudios.tk
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th May 2004 23:16
The source code looks fine.

If you want to send the media to me via , I'll trace it through and work out where the program is failing. Either Zip or RAR are fine.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 14th May 2004 00:20
I've emailed you at ian@matrix1.demon.co.uk with a .rar file of the graphics. Hope that helps.

Cheers


Visit the Code Monkey's website at http://www.codemonkeystudios.tk
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 14th May 2004 21:02
Any luck with the code?


Visit the Code Monkey's website at http://www.codemonkeystudios.tk
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th May 2004 21:12
Not yet. I took a little look last night, and corrected your collision code, but it still terminated without error. I've not taken a really in-depth look yet though.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th May 2004 00:44
Ok, here's a quick fix to keep your project moving for now.



The reason that its crashing is that the checking is extending past the end of the memblocks into memory not owned by the process.

I'll rework it tomorrow so that it does the job correctly.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 15th May 2004 23:11
Thanks for that Ian M. I'm just fiddling with it now. It doesnt crash any more it just falls straight through the platform. I think thats an error in my collision code though so i best still keep fiddling.

Cheers,

Michael


Visit the Code Monkey's website at http://www.codemonkeystudios.tk
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th May 2004 23:57
Yep, it's you. Here is the fix I made



*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 17th May 2004 01:06
Thanks fot that ian. What exactly does that exit command do?


Visit the Code Monkey's website at http://www.codemonkeystudios.tk
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th May 2004 01:14
It jumps you out of the current loop safely

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 17th May 2004 01:27
Ok. Thanks for all your help.


Visit the Code Monkey's website at http://www.codemonkeystudios.tk

Login to post a reply

Server time is: 2024-11-26 17:41:50
Your offset time is: 2024-11-26 17:41:50